Skip to content

Commit

Permalink
19163: Fixes memory corruption issue (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
howsohazard authored Jan 31, 2024
1 parent 7cf40dc commit 437238a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Amalgam/evaluablenode/EvaluableNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,12 @@ void EvaluableNode::InitializeType(EvaluableNode *n, bool copy_labels, bool copy

void EvaluableNode::CopyValueFrom(EvaluableNode *n)
{
//don't do anything if copying from itself (note that some flat hash map structures don't copy well onto themselves)
if(n == this)
return;

if(n == nullptr)
{

ClearOrderedChildNodes();
ClearMappedChildNodes();
//doesn't need an EvaluableNodeManager because not converting child nodes from one type to another
Expand Down Expand Up @@ -466,6 +469,10 @@ void EvaluableNode::CopyValueFrom(EvaluableNode *n)

void EvaluableNode::CopyMetadataFrom(EvaluableNode *n)
{
//don't do anything if copying from itself
if(n == this)
return;

//copy labels (different ways based on type)
if(HasCompactSingleLabelStorage() && n->HasCompactSingleLabelStorage())
{
Expand Down
2 changes: 0 additions & 2 deletions src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,10 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef

if(EvaluableNode::IsAssociativeArray(variable_value_node))
{
new_list->SetMappedChildNodes(value_destination_node->GetMappedChildNodes(), true);
new_list->AppendMappedChildNodes(variable_value_node->GetMappedChildNodes());
}
else if(variable_value_node != nullptr) //treat ordered pairs as new entries as long as not nullptr
{
new_list->SetMappedChildNodes(value_destination_node->GetMappedChildNodes(), true);
//iterate as long as pairs exist
auto &vvn_ocn = variable_value_node->GetOrderedChildNodes();
for(size_t i = 0; i + 1 < vvn_ocn.size(); i += 2)
Expand Down

0 comments on commit 437238a

Please sign in to comment.