Skip to content

Commit

Permalink
scripts: on fail realloc function does not free orig res but null it
Browse files Browse the repository at this point in the history
When a fail occurs, realloc function does null res, but does not free
the original res.

Signed-off-by: BELOUARGA Mohamed <[email protected]>
  • Loading branch information
BELOUARGA Mohamed authored and sbabic committed Feb 7, 2024
1 parent 7be4bca commit 90c6db1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ const char *sym_expand_string_value(const char *in)
{
const char *src;
char *res;
char *tmp_res;
size_t reslen;

reslen = strlen(in) + 1;
Expand Down Expand Up @@ -902,7 +903,10 @@ const char *sym_expand_string_value(const char *in)
newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
if (newlen > reslen) {
reslen = newlen;
res = realloc(res, reslen);
tmp_res = realloc(res, reslen);
if (!tmp_res)
free(res);
res = tmp_res;
}

strcat(res, symval);
Expand Down

0 comments on commit 90c6db1

Please sign in to comment.