summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-12-27 08:59:30 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-12-27 08:59:30 +0300
commitfad9ca55111a4a7bc6952bd7b56086d472023a9e (patch)
tree1f800525db947b51f4b298b7e6fcfa2cd4dc25c6
parentc87fd33b6b1a924e607e081c61e7e391edc4d21b (diff)
downloadbdwgc-fad9ca55111a4a7bc6952bd7b56086d472023a9e.tar.gz
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.
-rw-r--r--mallocx.c6
1 files changed, 5 insertions, 1 deletions
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);
}