From 332900a5542796a327a4b899042847095d9b7cc1 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 23 Dec 2012 14:47:09 +0400 Subject: [PATCH] Add assertion to LONG_MULT and remove useless assert in PUSH_CONTENTS_HDR * include/private/gc_pmark.h (LONG_MULT): Add static assertion that the size of variable is large enough to hold multiplication result. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Remove useless assertion check for a unsigned "high_prod" value to be non-negative (only if MARK_BIT_PER_OBJ). --- include/private/gc_pmark.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 67b64160..0192ef7c 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -229,6 +229,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); do { \ unsigned long long prod = (unsigned long long)(x) \ * (unsigned long long)(y); \ + GC_STATIC_ASSERT(sizeof(x) + sizeof(y) <= sizeof(prod)); \ hprod = prod >> 32; \ lprod = (unsigned32)prod; \ } while (0) @@ -345,7 +346,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); } \ /* May get here for pointer to start of block not at */ \ /* beginning of object. If so, it's valid, and we're fine. */ \ - GC_ASSERT(high_prod >= 0 && high_prod <= HBLK_OBJS(hhdr -> hb_sz)); \ + GC_ASSERT(high_prod <= HBLK_OBJS(hhdr -> hb_sz)); \ TRACE(source, GC_log_printf("GC #%u: passed validity tests\n", \ (unsigned)GC_gc_no)); \ SET_MARK_BIT_EXIT_IF_SET(hhdr, high_prod, exit_label); \ -- 2.40.0