From c2d90db660f780b7258e5ae2d9063607c0496df7 Mon Sep 17 00:00:00 2001 From: Jonny <21113168+Jonny0201@users.noreply.github.com> Date: Sat, 26 Jul 2025 14:11:35 +0800 Subject: [PATCH] Update listing_7.5.cpp - Undefined behaviour If `old_head` is a null pointer, `chain_pending_node` will read the member variable `next` from a null pointer. --- listings/listing_7.5.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/listings/listing_7.5.cpp b/listings/listing_7.5.cpp index b4e44c5..e172054 100644 --- a/listings/listing_7.5.cpp +++ b/listings/listing_7.5.cpp @@ -31,7 +31,10 @@ class lock_free_stack } else { - chain_pending_node(old_head); + if(old_head) + { + chain_pending_node(old_head); + } --threads_in_pop; } }