From 5f9634a2093fa9a0727ab07ca8a76a4fc5c57904 Mon Sep 17 00:00:00 2001 From: Tal500 Date: Wed, 21 May 2025 18:57:01 +0300 Subject: [PATCH] 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). --- simplecpp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/simplecpp.cpp b/simplecpp.cpp index 2316c42b..625674dd 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -3249,6 +3249,8 @@ std::map simplecpp::load(const simplecpp::To if (!f.is_open()) continue; f.close(); + if (ret.find(header2) != ret.end()) + continue; TokenList *tokens = new TokenList(header2, filenames, outputList); if (dui.removeComments)