Skip to content

Commit

Permalink
minor main opt leak
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Mar 31, 2021
1 parent 0a516c7 commit 7e01a4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
CMAKE_ARGS:
-
- -DCMAKE_BUILD_TYPE=Debug
- -DCMAKE_BUILD_TYPE=Asan
- -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,12 +1815,15 @@ int main ( int argc, const char ** argv )
char *rest = opt;
char *p;
bool found = false;
bool need_opt_free = false;
g_testAll = false;
do {
if ((p = strchr(rest, ','))) {
opt = strndup(rest, p-rest);
need_opt_free = true;
rest = p+1;
} else {
need_opt_free = false;
opt = rest;
}
for (size_t i = 0; i < sizeof(g_testopts) / sizeof(TestOpts); i++) {
Expand All @@ -1835,8 +1838,12 @@ int main ( int argc, const char ** argv )
printf(",%s", g_testopts[i].name);
}
printf(" \n");
if (need_opt_free)
free(opt);
exit(1);
}
if (need_opt_free)
free(opt);
} while (p);
continue;
}
Expand Down

0 comments on commit 7e01a4a

Please sign in to comment.