Check pointer is not NULL before passing to strlen

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/486/head
Selva Nair 2022-03-11 12:00:42 -05:00 committed by Gert Doering
parent 6271d2f674
commit 2cc5788367
1 changed files with 2 additions and 1 deletions

3
misc.c
View File

@ -171,7 +171,6 @@ char *
escape_string(const char *input)
{
char *out = strdup(input);
int len = strlen(out);
const char *esc = "\'\"\\ ";
if (!out)
@ -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]))