Fix memory leak for _parse_str in case of error.

This commit is contained in:
Patrick Pelissier committed 2020-05-24 19:50:32 +02:00
1 parent 9710e014f2
commit 9340c2e55c
6 files changed
+50 -45

No files matched your search

+6 -5
View File
@@ -880,7 +880,7 @@
{ \
ARRAYI_CONTRACT(array); \
assert (str != NULL); \
M_C(name,_clean)(array); \
M_C(name,_clean)(array); \
bool success = false; \
int c = *str++; \
if (M_UNLIKELY (c != '[')) goto exit; \
@@ -893,12 +893,13 @@
do { \
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
do { c = *str++; } while (isspace(c)); \
if (b == false || c == 0) { goto exit; } \
M_C(name, _push_back)(array, item); \
} while (c == M_GET_SEPARATOR oplist); \
M_CALL_CLEAR(oplist, item); \
if (b == false || c == 0) { goto exit_clear; } \
M_C(name, _push_back)(array, item); \
} while (c == M_GET_SEPARATOR oplist); \
ARRAYI_CONTRACT(array); \
success = (c == ']'); \
exit_clear: \
M_CALL_CLEAR(oplist, item); \
exit: \
if (endp) *endp = str; \
return success; \