From: Ivan Maidanski Date: Fri, 19 Oct 2012 04:58:46 +0000 (+0400) Subject: Check GC_base result in GC_print_all_smashed_proc X-Git-Tag: gc7_4_0~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d667d207ca6cc96316e7d8ed896b222c41d3137;p=gc Check GC_base result in GC_print_all_smashed_proc * dbg_mlc.c (GC_print_all_smashed_proc): Add a code for a LINT-like (static code analysis) tool to instruct it that GC_base is invoked only with valid GC_smashed[] elements (so its result passed to GC_print_smashed_obj is non-NULL). --- diff --git a/dbg_mlc.c b/dbg_mlc.c index 5229677d..d98195bb 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -918,8 +918,12 @@ STATIC void GC_print_all_smashed_proc(void) if (GC_n_smashed == 0) return; GC_err_printf("GC_check_heap_block: found smashed heap objects:\n"); for (i = 0; i < GC_n_smashed; ++i) { - GC_print_smashed_obj("", (ptr_t)GC_base(GC_smashed[i]) + sizeof(oh), - GC_smashed[i]); + ptr_t base = (ptr_t)GC_base(GC_smashed[i]); + +# ifdef LINT2 + if (!base) ABORT("Invalid GC_smashed element"); +# endif + GC_print_smashed_obj("", base + sizeof(oh), GC_smashed[i]); GC_smashed[i] = 0; } GC_n_smashed = 0;