Skip to content

Commit

Permalink
22497: Fixes segfaults for index_min and index_max with null keys (#341)
Browse files Browse the repository at this point in the history
Also cleans out unneeded method
  • Loading branch information
howsohazard authored Jan 9, 2025
1 parent bd48a59 commit 410684e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
10 changes: 0 additions & 10 deletions src/Amalgam/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Amalgam/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Amalgam/interpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 410684e

Please sign in to comment.