File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1693,7 +1693,9 @@ namespace simplecpp {
16931693 nameTokDef = nametoken;
16941694 variadic = false ;
16951695 variadicOpt = false ;
1696+ delete optExpandValue;
16961697 optExpandValue = nullptr ;
1698+ delete optNoExpandValue;
16971699 optNoExpandValue = nullptr ;
16981700 if (!nameTokDef) {
16991701 valueToken = endToken = nullptr ;
@@ -2367,8 +2369,8 @@ namespace simplecpp {
23672369 bool variadicOpt;
23682370
23692371 /* * Expansion value for varadic macros with __VA_OPT__ expanded and discarded respectively */
2370- const TokenList *optExpandValue;
2371- const TokenList *optNoExpandValue;
2372+ const TokenList *optExpandValue{} ;
2373+ const TokenList *optNoExpandValue{} ;
23722374
23732375 /* * was the value of this macro actually defined in the code? */
23742376 bool valueDefinedInCode_;
Original file line number Diff line number Diff line change @@ -3217,6 +3217,7 @@ static void safe_api()
32173217#endif
32183218}
32193219
3220+ // crashes detected by fuzzer
32203221static void fuzz_crash ()
32213222{
32223223 {
@@ -3231,6 +3232,16 @@ static void fuzz_crash()
32313232 }
32323233}
32333234
3235+ // memory leaks detected by LSAN/valgrind
3236+ static void leak ()
3237+ {
3238+ { // #498
3239+ const char code[] = " #define e(...)__VA_OPT__()\n "
3240+ " #define e\n " ;
3241+ (void )preprocess (code, simplecpp::DUI ());
3242+ }
3243+ }
3244+
32343245int main (int argc, char **argv)
32353246{
32363247 TEST_CASE (backslash);
@@ -3487,5 +3498,7 @@ int main(int argc, char **argv)
34873498
34883499 TEST_CASE (fuzz_crash);
34893500
3501+ TEST_CASE (leak);
3502+
34903503 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
34913504}
You can’t perform that action at this time.
0 commit comments