From 410684e7abf7872f0fbd37acf53155c69c534111 Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:24:42 -0500 Subject: [PATCH] 22497: Fixes segfaults for index_min and index_max with null keys (#341) Also cleans out unneeded method --- src/Amalgam/Parser.cpp | 10 ---------- src/Amalgam/Parser.h | 3 --- src/Amalgam/interpreter/Interpreter.h | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Amalgam/Parser.cpp b/src/Amalgam/Parser.cpp index 25919a4f..772fc0b3 100644 --- a/src/Amalgam/Parser.cpp +++ b/src/Amalgam/Parser.cpp @@ -149,16 +149,6 @@ std::string Parser::Unparse(EvaluableNode *tree, return upd.result; } -EvaluableNodeReference Parser::ParseFromKeyString(const std::string &code_string, EvaluableNodeManager *enm) -{ - if(code_string.size() == 0 || code_string[0] != '\0') - return EvaluableNodeReference(enm->AllocNode(ENT_STRING, code_string), true); - - std::string_view escaped_string(&code_string[1], code_string.size() - 1); - auto [node, warnings, char_with_error] = Parser::Parse(escaped_string, enm); - return node; -} - EvaluableNodeReference Parser::ParseFromKeyStringId(StringInternPool::StringID code_string_id, EvaluableNodeManager *enm) { diff --git a/src/Amalgam/Parser.h b/src/Amalgam/Parser.h index 57ece8d3..1a12b579 100644 --- a/src/Amalgam/Parser.h +++ b/src/Amalgam/Parser.h @@ -136,9 +136,6 @@ class Parser bool expanded_whitespace = true, bool emit_attributes = true, bool sort_keys = false, bool first_of_transactional_unparse = false, size_t starting_indendation = 0); - //transforms the code_string into evaluable nodes - static EvaluableNodeReference ParseFromKeyString(const std::string &code_string, EvaluableNodeManager *enm); - //transforms the code_string_id into evaluable nodes static EvaluableNodeReference ParseFromKeyStringId(StringInternPool::StringID code_string_id, EvaluableNodeManager *enm); diff --git a/src/Amalgam/interpreter/Interpreter.h b/src/Amalgam/interpreter/Interpreter.h index 973bc491..6104238e 100644 --- a/src/Amalgam/interpreter/Interpreter.h +++ b/src/Amalgam/interpreter/Interpreter.h @@ -1314,7 +1314,7 @@ class Interpreter for(StringInternPool::StringID max_key : max_keys) { - EvaluableNodeReference parsedKey = Parser::ParseFromKeyString(max_key->string, evaluableNodeManager); + EvaluableNodeReference parsedKey = Parser::ParseFromKeyStringId(max_key, evaluableNodeManager); index_list.UpdatePropertiesBasedOnAttachedNode(parsedKey); index_list_ocn.push_back(parsedKey); }