Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,9 @@ namespace simplecpp {
nameTokDef = nametoken;
variadic = false;
variadicOpt = false;
delete optExpandValue;
optExpandValue = nullptr;
delete optNoExpandValue;
optNoExpandValue = nullptr;
if (!nameTokDef) {
valueToken = endToken = nullptr;
Expand Down Expand Up @@ -2367,8 +2369,8 @@ namespace simplecpp {
bool variadicOpt;

/** Expansion value for varadic macros with __VA_OPT__ expanded and discarded respectively */
const TokenList *optExpandValue;
const TokenList *optNoExpandValue;
const TokenList *optExpandValue{};
const TokenList *optNoExpandValue{};

/** was the value of this macro actually defined in the code? */
bool valueDefinedInCode_;
Expand Down
13 changes: 13 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3217,6 +3217,7 @@ static void safe_api()
#endif
}

// crashes detected by fuzzer
static void fuzz_crash()
{
{
Expand All @@ -3231,6 +3232,16 @@ static void fuzz_crash()
}
}

// memory leaks detected by LSAN/valgrind
static void leak()
{
{ // #498
const char code[] = "#define e(...)__VA_OPT__()\n"
"#define e\n";
(void)preprocess(code, simplecpp::DUI());
}
}

int main(int argc, char **argv)
{
TEST_CASE(backslash);
Expand Down Expand Up @@ -3487,5 +3498,7 @@ int main(int argc, char **argv)

TEST_CASE(fuzz_crash);

TEST_CASE(leak);

return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}