Skip to content

Commit

Permalink
Free allocated pointer on OOM error
Browse files Browse the repository at this point in the history
If the allocation of str fails, free the previous memory allocation
in the error path.
  • Loading branch information
danielgustafsson committed May 5, 2024
1 parent 268e144 commit 696109b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ static struct string *memdupdec(char *source, size_t len, bool json)
curl_free(left);
ret = malloc(sizeof(struct string));
if(!ret) {
free(str);
return NULL;
}
ret->str = str;
Expand Down

0 comments on commit 696109b

Please sign in to comment.