Sebastian Lackner : server: Explicitly mark memory as undefined in mem_alloc wrapper.
Alexandre Julliard
julliard at winehq.org
Thu Mar 9 15:51:33 CST 2017
Module: wine
Branch: master
Commit: 332d59215846e773375b9bd02411c0de63055953
URL: http://source.winehq.org/git/wine.git/?a=commit;h=332d59215846e773375b9bd02411c0de63055953
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Wed Mar 8 04:40:47 2017 +0100
server: Explicitly mark memory as undefined in mem_alloc wrapper.
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
server/object.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/server/object.c b/server/object.c
index ad22ec1..e43fe3f 100644
--- a/server/object.c
+++ b/server/object.c
@@ -28,6 +28,9 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -92,11 +95,22 @@ void close_objects(void)
/*****************************************************************/
+/* mark a block of memory as uninitialized for debugging purposes */
+static inline void mark_block_uninitialized( void *ptr, size_t size )
+{
+ memset( ptr, 0x55, size );
+#if defined(VALGRIND_MAKE_MEM_UNDEFINED)
+ VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size ));
+#elif defined(VALGRIND_MAKE_WRITABLE)
+ VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size ));
+#endif
+}
+
/* malloc replacement */
void *mem_alloc( size_t size )
{
void *ptr = malloc( size );
- if (ptr) memset( ptr, 0x55, size );
+ if (ptr) mark_block_uninitialized( ptr, size );
else set_error( STATUS_NO_MEMORY );
return ptr;
}
More information about the wine-cvs
mailing list