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-27 14:04:52 +0300
commitc9a1736b038e85da8444789825cb382aef4ecdb2 (patch)
tree4e2ea0a60cb2faff516c59f34b21ff416bb36405
parenta63e6e8abad6880ed19f80e73523403d303cea48 (diff)
downloadbdwgc-c9a1736b038e85da8444789825cb382aef4ecdb2.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 6de59e35..d86af0c6 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -223,7 +223,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)