aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2017-11-29 11:22:44 (GMT)
committerJouni Malinen <j@w1.fi>2017-11-29 11:22:44 (GMT)
commit281f480c531f950fd3ed4dfc507aa3b2bebf942c (patch)
treedea0de3a7d2984f19a536b6dbd196ef04c5d332e
parent622934128b9938c060aef0a4c5b96aad4436fd59 (diff)
downloadhostap-281f480c531f950fd3ed4dfc507aa3b2bebf942c.zip
hostap-281f480c531f950fd3ed4dfc507aa3b2bebf942c.tar.gz
hostap-281f480c531f950fd3ed4dfc507aa3b2bebf942c.tar.bz2
JSON: Fix a memory leak on an error path
If the second json_alloc_token() call failed to allocate memory, json_parse() missed the first allocation on the error path. Assign the root pointer earlier for that case to avoid the potential memory leak. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--src/utils/json.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/utils/json.c b/src/utils/json.c
index eae627d..b9130d3 100644
--- a/src/utils/json.c
+++ b/src/utils/json.c
@@ -230,6 +230,8 @@ struct json_token * json_parse(const char *data, size_t data_len)
token = json_alloc_token(&tokens);
if (!token)
goto fail;
+ if (!root)
+ root = token;
} else if (curr_token->state == JSON_WAITING_VALUE) {
token = curr_token;
} else if (curr_token->parent &&