cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=743c80ad8b86155dd47c711a05ceaab66d90dfc0

commit 743c80ad8b86155dd47c711a05ceaab66d90dfc0
Author: Cedric Bail <ced...@osg.samsung.com>
Date:   Tue Sep 5 17:01:03 2017 -0700

    eina: properly mark memory for valgrind before accessing it in one_big 
mempool.
---
 src/modules/eina/mp/one_big/eina_one_big.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/modules/eina/mp/one_big/eina_one_big.c 
b/src/modules/eina/mp/one_big/eina_one_big.c
index f3d2e4c29e..c816970621 100644
--- a/src/modules/eina/mp/one_big/eina_one_big.c
+++ b/src/modules/eina/mp/one_big/eina_one_big.c
@@ -162,7 +162,7 @@ eina_one_big_free(void *data, void *ptr)
         pool->usage--;
 
 #ifndef NVALGRIND
-        VALGRIND_MEMPOOL_FREE(pool, ptr);
+        VALGRIND_MAKE_MEM_NOACCESS(ptr, pool->item_size);
 #endif
      }
    else
@@ -210,6 +210,9 @@ eina_one_big_from(void *data, void *ptr)
        && ptr < (void *)(pool->base + (pool->max * pool->item_size)))
      {
         Eina_Trash *t;
+#ifndef NVALGRIND
+        Eina_Trash *last = NULL;
+#endif
         // Part of the bigger area
 
         // Check if it is a properly aligned element
@@ -224,7 +227,17 @@ eina_one_big_from(void *data, void *ptr)
 
         // Check if the pointer was freed
         for (t = pool->empty; t != NULL; t = t->next)
-          if (t == ptr) goto end;
+          {
+#ifndef NVALGRIND
+             VALGRIND_MAKE_MEM_DEFINED(t, pool->item_size);
+             if (last) VALGRIND_MAKE_MEM_NOACCESS(last, pool->item_size);
+             last = t;
+#endif
+             if (t == ptr) goto end;
+          }
+#ifndef NVALGRIND
+        if (last) VALGRIND_MAKE_MEM_NOACCESS(last, pool->item_size);
+#endif
 
         // Everything seems correct
         r = EINA_TRUE;

-- 


Reply via email to