Skip to content

Commit

Permalink
Fix malloc error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
l2dy committed Mar 9, 2020
1 parent 31fc3b6 commit c58df36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cfg_pp.c
Expand Up @@ -546,6 +546,11 @@ void cfg_dump_context(const char *file, int line, int colstart, int colend)
/* error indicator line */
len = strlen(con->lines[i-1]);
wsbuf = malloc(len + 1);
if (wsbuf == NULL) {
LM_ERR("NO MEMORY\n");
return;
}

wb = wsbuf;
for (p = con->lines[i-1], end = p + len; p < end && is_ws(*p); p++)
*wb++ = *p;
Expand All @@ -555,6 +560,10 @@ void cfg_dump_context(const char *file, int line, int colstart, int colend)
hiline = NULL;
} else {
hiline = malloc(colend - colstart);
if (hiline == NULL) {
LM_ERR("NO MEMORY\n");
return;
}
memset(hiline, '~', colend - colstart);
}

Expand Down

0 comments on commit c58df36

Please sign in to comment.