]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Out-of-spec use of POSIX barriers could make drd crash -- fixed this.
authorBart Van Assche <bvanassche@acm.org>
Mon, 7 Jul 2008 08:17:55 +0000 (08:17 +0000)
committerBart Van Assche <bvanassche@acm.org>
Mon, 7 Jul 2008 08:17:55 +0000 (08:17 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8374

drd/drd_barrier.c

index 762418039a03935a1a50fdef1d391e7581d8265b..fac3eb73c05240827ce3074fa2a0280a7d98ccfb 100644 (file)
@@ -84,6 +84,7 @@ static void barrier_thread_initialize(struct barrier_thread_info* const p,
 /** Deallocate the memory that was allocated in barrier_thread_initialize(). */
 static void barrier_thread_destroy(struct barrier_thread_info* const p)
 {
+  tl_assert(p);
   sg_put(p->sg[0]);
   sg_put(p->sg[1]);
 }
@@ -409,8 +410,11 @@ void barrier_thread_delete(const DrdThreadId tid)
     struct barrier_thread_info* q;
     const UWord word_tid = tid;
     q = VG_(OSetGen_Remove)(p->oset, &word_tid);
-    barrier_thread_destroy(q);
-    VG_(OSetGen_FreeNode)(p->oset, q);
+    if (q)
+    {
+      barrier_thread_destroy(q);
+      VG_(OSetGen_FreeNode)(p->oset, q);
+    }
   }
 }