From 79f1c2d60acd20393a4337b2f4486ed3df2c166a Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Sun, 19 Jan 2025 00:06:03 +0000 Subject: [PATCH] erase functions have bugs Before calling them would either lead to an exception being thrown or a null pointer dereference. Signed-off-by: Eric Curtin --- include/minja/minja.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/minja/minja.hpp b/include/minja/minja.hpp index 8b6c243..4516e4e 100644 --- a/include/minja/minja.hpp +++ b/include/minja/minja.hpp @@ -367,11 +367,11 @@ class Value : public std::enable_shared_from_this { } } void erase(size_t index) { - if (array_) throw std::runtime_error("Value is not an array: " + dump()); + if (!array_) throw std::runtime_error("Value is not an array: " + dump()); array_->erase(array_->begin() + index); } void erase(const std::string & key) { - if (object_) throw std::runtime_error("Value is not an object: " + dump()); + if (!object_) throw std::runtime_error("Value is not an object: " + dump()); object_->erase(key); } const Value& at(const Value & index) const {