Skip to content

Commit

Permalink
Check pointer is not NULL before passing to strlen
Browse files Browse the repository at this point in the history
Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair authored and cron2 committed Mar 11, 2022
1 parent 6271d2f commit 2cc5788
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ char *
escape_string(const char *input)
{
char *out = strdup(input);
int len = strlen(out);
const char *esc = "\'\"\\ ";

if (!out)
Expand All @@ -180,6 +179,8 @@ escape_string(const char *input)
return NULL;
}

int len = strlen(out);

for (int pos = 0; pos < len; ++pos)
{
if (strchr(esc, out[pos]))
Expand Down

0 comments on commit 2cc5788

Please sign in to comment.