]> granicus.if.org Git - gc/commitdiff
Eliminate 'null dereference' code defect warning in register_finalizer
authorIvan Maidanski <ivmai@mail.ru>
Sat, 29 Oct 2016 14:49:37 +0000 (17:49 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 1 Nov 2016 21:41:59 +0000 (00:41 +0300)
* finalize.c (GC_register_finalizer_inner): Add GC_ASSERT that fn is
non-zero (instead of specifying this in a comment) for the case when
new_fo is non-NULL (new_fo is returned by GC_oom_fn).
* finalize.c [LINT2] (GC_register_finalizer_inner): Call ABORT if hhdr
is NULL (for the case when new_fo is non-NULL).

finalize.c

index 8cd5a204bc61ba146c4e7d67fd5d4a554bb06b9b..b58a883320fd837e01ae5cfaca015bc9d847be43 100644 (file)
@@ -700,7 +700,11 @@ STATIC void GC_register_finalizer_inner(void * obj,
         curr_fo = fo_next(curr_fo);
       }
       if (EXPECT(new_fo != 0, FALSE)) {
-        /* new_fo is returned by GC_oom_fn(), so fn != 0 and hhdr != 0. */
+        /* new_fo is returned by GC_oom_fn().   */
+        GC_ASSERT(fn != 0);
+#       ifdef LINT2
+          if (NULL == hhdr) ABORT("Bad hhdr in GC_register_finalizer_inner");
+#       endif
         break;
       }
       if (fn == 0) {