mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Fix memory leak in case allocation of token fails during JSON parsing
On failure of json_alloc_token(), json_parse() can return without freeing 'str' previously allocated by json_parse_string(). Fix this adding proper call to os_free(). Signed-off-by: Davide Caratti <davide.caratti@gmail.com>
This commit is contained in:
parent
84877f253d
commit
2ba6aa6045
@ -300,8 +300,10 @@ struct json_token * json_parse(const char *data, size_t data_len)
|
|||||||
goto fail;
|
goto fail;
|
||||||
if (!curr_token) {
|
if (!curr_token) {
|
||||||
token = json_alloc_token(&tokens);
|
token = json_alloc_token(&tokens);
|
||||||
if (!token)
|
if (!token) {
|
||||||
|
os_free(str);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
token->type = JSON_STRING;
|
token->type = JSON_STRING;
|
||||||
token->string = str;
|
token->string = str;
|
||||||
token->state = JSON_COMPLETED;
|
token->state = JSON_COMPLETED;
|
||||||
|
Loading…
Reference in New Issue
Block a user