Skip to content

Commit

Permalink
Better robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
makuke1234 committed Apr 13, 2022
1 parent 64571ba commit 52882e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,27 @@ bool scanargs(
size_t numArgs
)
{
bool marked[argc];
memset(marked, 0, sizeof(bool) * (size_t)argc);
bool * marked = calloc((size_t)argc, sizeof(bool));
if (marked == NULL)
{
return false;
}

for (size_t i = 0; i < numArgs; ++i)
{
if (!scanarg(argc, argv, helpflag, marked, false, formats[i], bufs[i]))
{
free(marked);
return false;
}
if (*helpflag)
{
free(marked);
return true;
}
}

free(marked);
return true;
}

Expand Down

0 comments on commit 52882e3

Please sign in to comment.