From 6a2a5948fb4966ba3ebbe64901afd085473b544c Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 10 Jan 2023 22:32:14 -0500 Subject: [PATCH] Fix null issue --- include/blt/std/binary_tree.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/blt/std/binary_tree.h b/include/blt/std/binary_tree.h index 1d08e67..a4fe660 100644 --- a/include/blt/std/binary_tree.h +++ b/include/blt/std/binary_tree.h @@ -71,12 +71,14 @@ namespace blt { return nullptr; // check for left and right tree traversal if it exists if (searchNode->left != nullptr && element < searchNode->left->payload) { - *parent = searchNode; + if (parent != nullptr) + *parent = searchNode; searchNode = searchNode->left; continue; } if (searchNode->right != nullptr && element > searchNode->right->payload) { - *parent = searchNode; + if (parent != nullptr) + *parent = searchNode; searchNode = searchNode->right; continue; }