From fad9ca55111a4a7bc6952bd7b56086d472023a9e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 27 Dec 2021 08:59:30 +0300 Subject: Eliminate 'buffer overflow detected' FP error in realloc_test Issue #406 (bdwgc). * mallocx.c (GC_realloc): Pass p to BZERO() thru an intermediate variable of word type; add comment. --- mallocx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mallocx.c') diff --git a/mallocx.c b/mallocx.c index 0a1366a8..4e65fa09 100644 --- a/mallocx.c +++ b/mallocx.c @@ -146,7 +146,11 @@ GC_API void * GC_CALL GC_realloc(void * p, size_t lb) if (orig_sz > lb) { /* Clear unneeded part of object to avoid bogus pointer */ /* tracing. */ - BZERO(((ptr_t)p) + lb, orig_sz - lb); + word cleared_p = (word)p; + /* A workaround to avoid passing alloc_size(lb) */ + /* attribute associated with p to memset. */ + + BZERO((ptr_t)cleared_p + lb, orig_sz - lb); } return(p); } -- cgit v1.2.1