From b280a10c850e05581d8eec8eb10b49b49e442aa5 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 29 Oct 2016 17:49:37 +0300 Subject: [PATCH] Eliminate 'null dereference' code defect warning in register_finalizer * 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/finalize.c b/finalize.c index 3de2a9c8..c765d628 100644 --- a/finalize.c +++ b/finalize.c @@ -699,7 +699,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) { -- 2.40.0