summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-08 13:00:11 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-28 19:48:44 +0300
commit9c6c618cc6512cbe4449acae4417a785c67da4ac (patch)
tree0e1b12da4f4ee4c037e75095130a8cbd63c01dd2
parentab9c128262ddfbd267d300168ad86f11fc8c13cd (diff)
downloadbdwgc-9c6c618cc6512cbe4449acae4417a785c67da4ac.tar.gz
Fix null pointer dereference in TRACE_TARGET
* include/private/gc_pmark.h [ENABLE_TRACE] (TRACE_TARGET): Do not dereference GC_trace_addr if it is not a pointer to a heap object.
-rw-r--r--include/private/gc_pmark.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index 15e79860..ad29f3d8 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -225,7 +225,8 @@ GC_INLINE mse * GC_push_obj(ptr_t obj, hdr * hhdr, mse * mark_stack_top,
# define TRACE(source, cmd) \
if (GC_trace_addr != 0 && (ptr_t)(source) == GC_trace_addr) cmd
# define TRACE_TARGET(target, cmd) \
- if (GC_trace_addr != 0 && (target) == *(ptr_t *)GC_trace_addr) cmd
+ if (GC_trace_addr != NULL && GC_is_heap_ptr(GC_trace_addr) \
+ && (target) == *(ptr_t *)GC_trace_addr) cmd
#else
# define TRACE(source, cmd)
# define TRACE_TARGET(source, cmd)