]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DRD: Always invoke VG_(cli_free)() before the stop_using_mem callback.
authorBart Van Assche <bvanassche@acm.org>
Sat, 12 Mar 2011 12:43:39 +0000 (12:43 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 12 Mar 2011 12:43:39 +0000 (12:43 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11633

drd/drd_clientreq.c
drd/drd_malloc_wrappers.c
drd/drd_malloc_wrappers.h

index 8e9eb8256531dc9df90723199f41f28a734cb421..a64bd852e8fd2bad0db1d4e9ce748ce8a33c1d16 100644 (file)
@@ -81,7 +81,7 @@ static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
       break;
 
    case VG_USERREQ__FREELIKE_BLOCK:
-      if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/))
+      if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/, False))
       {
          GenericErrInfo GEI = {
            .tid = DRD_(thread_get_running_tid)(),
index 6eeffdb269da3a0ac62e4d858c852fed8d4d0614..7b594ffc7078fe4cb345d6d87d8d4350e95e340a 100644 (file)
@@ -109,19 +109,18 @@ void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size)
 
 static void handle_free(ThreadId tid, void* p)
 {
-   tl_assert(p);
+   Bool success;
 
-   if (DRD_(freelike_block)(tid, (Addr)p))
-      VG_(cli_free)(p);
-   else
-      tl_assert(False);
+   tl_assert(p);
+   success = DRD_(freelike_block)(tid, (Addr)p, True);
+   tl_assert(success);
 }
 
 /**
  * Remove the information that was stored by DRD_(malloclike_block)() about
  * a memory block.
  */
-Bool DRD_(freelike_block)(const ThreadId tid, const Addr p)
+Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc)
 {
    DRD_Chunk* mc;
 
@@ -133,6 +132,8 @@ Bool DRD_(freelike_block)(const ThreadId tid, const Addr p)
    if (mc)
    {
       tl_assert(p == mc->data);
+      if (dealloc)
+        VG_(cli_free)((void*)p);
       if (mc->size > 0)
          s_stop_using_mem_callback(mc->data, mc->size);
       VG_(free)(mc);
index 2f9c2cece6ad56e199560f81f81fe84bbf71ce3e..d41464d30e4c033064f6122cd4c259ed04baa91f 100644 (file)
@@ -38,7 +38,7 @@ typedef void (*StopUsingMem)(const Addr a1, const SizeT len);
 void DRD_(register_malloc_wrappers)(const StartUsingMem start_callback,
                                     const StopUsingMem stop_callback);
 void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size);
-Bool DRD_(freelike_block)(const ThreadId tid, const Addr p);
+Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc);
 Bool DRD_(heap_addrinfo)(Addr const a,
                          Addr* const data,
                          SizeT* const size,