Merge pull request #26 from QuantamHD/fix_memory_leak

Fixes memory leak in verilog attribute code.
This commit is contained in:
James Cherry 2024-04-23 12:39:14 -07:00 committed by GitHub
commit 1b5c4e2745
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -505,9 +505,14 @@ attr_specs:
attr_spec: attr_spec:
ID ID
{ $$ = new sta::VerilogAttributeEntry($1, "1"); } { $$ = new sta::VerilogAttributeEntry($1, "1");
delete[] $1;
}
| ID '=' attr_spec_value | ID '=' attr_spec_value
{ $$ = new sta::VerilogAttributeEntry($1, $3); } { $$ = new sta::VerilogAttributeEntry($1, $3);
delete[] $1;
delete[] $3;
}
; ;
attr_spec_value: attr_spec_value:

View File

@ -424,8 +424,11 @@ VerilogReader::makeDcl(PortDirection *dir,
dcl_count_++; dcl_count_++;
return new VerilogDcl(dir, assign_args, attribute_stmts, line); return new VerilogDcl(dir, assign_args, attribute_stmts, line);
} }
else else {
attribute_stmts->deleteContents();
delete attribute_stmts;
return nullptr; return nullptr;
}
} }
else { else {
dcl_count_++; dcl_count_++;