[VM/Coverage] Fix memory leak in coverage code.

TEST=ci (existing test which was failing and should pass now)

Bug:51209
Change-Id: Ia156200af2b1271677f0a8ff576998b255adc964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280600
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
This commit is contained in:
asiva
2023-02-03 23:35:53 +00:00
committed by Commit Queue
parent 87810072db
commit dae49a0ca2
+10 -2
View File
@@ -55,12 +55,20 @@ SourceReport::~SourceReport() {
}
void SourceReport::ClearScriptTable() {
// Delete entries from script_table_ as it has the unfiltered list.
DirectChainedHashMap<ScriptTableTrait>::Iterator iter =
script_table_.GetIterator();
ScriptTableTrait::Pair* pair;
while ((pair = iter.Next()) != nullptr) {
delete ScriptTableTrait::ValueOf(*pair);
}
script_table_.Clear();
for (intptr_t i = 0; i < script_table_entries_.length(); i++) {
delete script_table_entries_[i];
script_table_entries_[i] = NULL;
}
script_table_entries_.Clear();
script_table_.Clear();
next_script_index_ = 0;
}