Skip to content

Commit 5f9634a

Browse files
authored
fix: leak + double header tokenizing in simplecpp::load
This was catched using the leak sanitizer that is part of the address sanitizer. On the line `ret[header2] = tokens;`, sometimes there is already a key `header2` in the `ret` map, causing both overriding(leak) and wasteful header tokenizing (two times at least).
1 parent 62afdd0 commit 5f9634a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

simplecpp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,6 +3249,8 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
32493249
if (!f.is_open())
32503250
continue;
32513251
f.close();
3252+
if (ret.find(header2) != ret.end())
3253+
continue;
32523254

32533255
TokenList *tokens = new TokenList(header2, filenames, outputList);
32543256
if (dui.removeComments)

0 commit comments

Comments
 (0)