From b7bce91292aa6078ce36d09c7818a5cd30d8f7df Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 26 Oct 2016 00:56:02 +0300 Subject: [PATCH] Eliminate 'dereference of null' CSA false warning in array_mark_proc The exact warning message is: Access to field 'mse_start' results in a dereference of a null pointer (loaded from variable 'new_mark_stack_ptr'). Note: the warning is eliminated regardless of assertion checking status. * typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL (thus orig_mark_stack_ptr is ensured to be non-NULL after the check). --- typd_mlc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typd_mlc.c b/typd_mlc.c index 7fde0a8..d19e4c1 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -495,6 +495,9 @@ STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr, mark_stack_ptr, mark_stack_limit-1); if (new_mark_stack_ptr == 0) { + /* Explicitly instruct Clang Static Analyzer that ptr is non-null. */ + if (NULL == mark_stack_ptr) ABORT("Bad mark_stack_ptr"); + /* Doesn't fit. Conservatively push the whole array as a unit */ /* and request a mark stack expansion. */ /* This cannot cause a mark stack overflow, since it replaces */ -- 2.7.4