File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1709,7 +1709,9 @@ namespace simplecpp {
1709
1709
nameTokDef = nametoken;
1710
1710
variadic = false ;
1711
1711
variadicOpt = false ;
1712
+ delete optExpandValue;
1712
1713
optExpandValue = nullptr ;
1714
+ delete optNoExpandValue;
1713
1715
optNoExpandValue = nullptr ;
1714
1716
if (!nameTokDef) {
1715
1717
valueToken = endToken = nullptr ;
@@ -2383,8 +2385,8 @@ namespace simplecpp {
2383
2385
bool variadicOpt;
2384
2386
2385
2387
/* * Expansion value for varadic macros with __VA_OPT__ expanded and discarded respectively */
2386
- const TokenList *optExpandValue;
2387
- const TokenList *optNoExpandValue;
2388
+ const TokenList *optExpandValue{} ;
2389
+ const TokenList *optNoExpandValue{} ;
2388
2390
2389
2391
/* * was the value of this macro actually defined in the code? */
2390
2392
bool valueDefinedInCode_;
Original file line number Diff line number Diff line change @@ -3246,6 +3246,7 @@ static void safe_api()
3246
3246
#endif
3247
3247
}
3248
3248
3249
+ // crashes detected by fuzzer
3249
3250
static void fuzz_crash ()
3250
3251
{
3251
3252
{
@@ -3260,6 +3261,16 @@ static void fuzz_crash()
3260
3261
}
3261
3262
}
3262
3263
3264
+ // memory leaks detected by LSAN/valgrind
3265
+ static void leak ()
3266
+ {
3267
+ { // #498
3268
+ const char code[] = " #define e(...)__VA_OPT__()\n "
3269
+ " #define e\n " ;
3270
+ (void )preprocess (code, simplecpp::DUI ());
3271
+ }
3272
+ }
3273
+
3263
3274
int main (int argc, char **argv)
3264
3275
{
3265
3276
TEST_CASE (backslash);
@@ -3516,5 +3527,7 @@ int main(int argc, char **argv)
3516
3527
3517
3528
TEST_CASE (fuzz_crash);
3518
3529
3530
+ TEST_CASE (leak);
3531
+
3519
3532
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
3520
3533
}
You can’t perform that action at this time.
0 commit comments