summaryrefslogtreecommitdiff
path: root/user/valgrind/realloc.patch
blob: d0eb795b84be4ca8d5369898774e24a4f4534b72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--- valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c
+++ valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c
@@ -765,13 +765,15 @@ static void init(void);
       DO_INIT; \
       MALLOC_TRACE("realloc(%p,%llu)", ptrV, (ULong)new_size ); \
       \
-      if (ptrV == NULL) \
-         /* We need to call a malloc-like function; so let's use \
-            one which we know exists. */ \
-         return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \
-                   (new_size); \
+      if (ptrV == NULL) { \
+         TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(new_size); \
+         v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_malloc, new_size ); \
+         MALLOC_TRACE(" = %p\n", v ); \
+         return v; \
+      } \
       if (new_size <= 0) { \
-         VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \
+         if (ptrV != NULL)  \
+            VALGRIND_NON_SIMD_CALL1( info.tl_free, ptrV ); \
          MALLOC_TRACE(" = 0\n"); \
          return NULL; \
       } \