Fix memory leak for _parse_str in case of error.
This commit is contained in:
1 parent
9710e014f2
commit
9340c2e55c
6 files changed
+27
-22
No files matched your search
@@ -893,12 +893,13 @@
|
|||||||
do { \
|
do { \
|
||||||
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c == 0) { goto exit; } \
|
if (b == false || c == 0) { goto exit_clear; } \
|
||||||
M_C(name, _push_back)(array, item); \
|
M_C(name, _push_back)(array, item); \
|
||||||
} while (c == M_GET_SEPARATOR oplist); \
|
} while (c == M_GET_SEPARATOR oplist); \
|
||||||
M_CALL_CLEAR(oplist, item); \
|
|
||||||
ARRAYI_CONTRACT(array); \
|
ARRAYI_CONTRACT(array); \
|
||||||
success = (c == ']'); \
|
success = (c == ']'); \
|
||||||
|
exit_clear: \
|
||||||
|
M_CALL_CLEAR(oplist, item); \
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
+10
-10
@@ -1198,24 +1198,24 @@
|
|||||||
M_CALL_INIT(key_oplist, key); \
|
M_CALL_INIT(key_oplist, key); \
|
||||||
M_IF(isMap)(value_t value; \
|
M_IF(isMap)(value_t value; \
|
||||||
M_CALL_INIT(value_oplist, value); \
|
M_CALL_INIT(value_oplist, value); \
|
||||||
,) \
|
, /* No isMap */) \
|
||||||
do { \
|
do { \
|
||||||
bool b = M_CALL_PARSE_STR(key_oplist, key, str, &str); \
|
bool b = M_CALL_PARSE_STR(key_oplist, key, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false) goto exit; \
|
if (b == false) goto exit_clear; \
|
||||||
M_IF(isMap)(if (c != ':') goto exit; \
|
M_IF(isMap)(if (c != ':') goto exit_clear; \
|
||||||
b = M_CALL_PARSE_STR(value_oplist, value, str, &str); \
|
b = M_CALL_PARSE_STR(value_oplist, value, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c == 0) goto exit; \
|
if (b == false || c == 0) goto exit_clear; \
|
||||||
M_C(name, _set_at)(t1, key, value) \
|
M_C(name, _set_at)(t1, key, value); \
|
||||||
, \
|
, \
|
||||||
M_C(name, _push)(t1, key) \
|
M_C(name, _push)(t1, key); \
|
||||||
); \
|
) \
|
||||||
} while (c == M_GET_SEPARATOR key_oplist); \
|
} while (c == M_GET_SEPARATOR key_oplist); \
|
||||||
M_CALL_CLEAR(key_oplist, key); \
|
|
||||||
M_IF(isMap)(M_CALL_CLEAR(value_oplist, value); \
|
|
||||||
,) \
|
|
||||||
success = (c == ']'); \
|
success = (c == ']'); \
|
||||||
|
exit_clear: \
|
||||||
|
M_CALL_CLEAR(key_oplist, key); \
|
||||||
|
M_IF(isMap)(M_CALL_CLEAR(value_oplist, value); , /* No isMap */ ) \
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
@@ -860,12 +860,13 @@
|
|||||||
do { \
|
do { \
|
||||||
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c == 0) { goto exit; } \
|
if (b == false || c == 0) { goto exit_clear; } \
|
||||||
M_C(name, _push_back)(deque, item); \
|
M_C(name, _push_back)(deque, item); \
|
||||||
} while (c == M_GET_SEPARATOR oplist); \
|
} while (c == M_GET_SEPARATOR oplist); \
|
||||||
M_CALL_CLEAR(oplist, item); \
|
|
||||||
DEQUEI_CONTRACT(deque); \
|
DEQUEI_CONTRACT(deque); \
|
||||||
success = (c == ']'); \
|
success = (c == ']'); \
|
||||||
|
exit_clear: \
|
||||||
|
M_CALL_CLEAR(oplist, item); \
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
@@ -759,20 +759,21 @@
|
|||||||
while (isspace((int) *str)) str++; \
|
while (isspace((int) *str)) str++; \
|
||||||
bool b = M_CALL_PARSE_STR(key_oplist, key, str, &str); \
|
bool b = M_CALL_PARSE_STR(key_oplist, key, str, &str); \
|
||||||
M_IF(isSet)( \
|
M_IF(isSet)( \
|
||||||
if (b == false) { break; } \
|
if (b == false) { goto exit_clear; } \
|
||||||
M_C(name, _push)(dict, key); \
|
M_C(name, _push)(dict, key); \
|
||||||
, \
|
, \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c != ':') { goto exit; } \
|
if (b == false || c != ':') { goto exit_clear; } \
|
||||||
b = M_CALL_PARSE_STR(value_oplist, value, str, &str); \
|
b = M_CALL_PARSE_STR(value_oplist, value, str, &str); \
|
||||||
if (b == false) { goto exit; } \
|
if (b == false) { goto exit_clear; } \
|
||||||
M_C(name, _set_at)(dict, key, value); \
|
M_C(name, _set_at)(dict, key, value); \
|
||||||
) \
|
) \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
} while (c == ','); \
|
} while (c == ','); \
|
||||||
|
success = (c == '}'); \
|
||||||
|
exit_clear: \
|
||||||
M_CALL_CLEAR(key_oplist, key); \
|
M_CALL_CLEAR(key_oplist, key); \
|
||||||
M_CALL_CLEAR(value_oplist, value); \
|
M_CALL_CLEAR(value_oplist, value); \
|
||||||
success = (c == '}'); \
|
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
@@ -697,12 +697,13 @@
|
|||||||
do { \
|
do { \
|
||||||
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c == 0) { goto exit; } \
|
if (b == false || c == 0) { goto exit_clear; } \
|
||||||
M_C(name, _push_back)(list, item); \
|
M_C(name, _push_back)(list, item); \
|
||||||
} while (c == M_GET_SEPARATOR oplist); \
|
} while (c == M_GET_SEPARATOR oplist); \
|
||||||
M_CALL_CLEAR(oplist, item); \
|
|
||||||
M_C(name, _reverse)(list); \
|
M_C(name, _reverse)(list); \
|
||||||
success = (c == ']'); \
|
success = (c == ']'); \
|
||||||
|
exit_clear: \
|
||||||
|
M_CALL_CLEAR(oplist, item); \
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
+3
-2
@@ -1002,11 +1002,12 @@ typedef enum {
|
|||||||
do { \
|
do { \
|
||||||
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
bool b = M_CALL_PARSE_STR(oplist, item, str, &str); \
|
||||||
do { c = *str++; } while (isspace(c)); \
|
do { c = *str++; } while (isspace(c)); \
|
||||||
if (b == false || c == 0) goto exit; \
|
if (b == false || c == 0) goto exit_clear; \
|
||||||
M_C(name, _push)(rbtree, item); \
|
M_C(name, _push)(rbtree, item); \
|
||||||
} while (c == M_GET_SEPARATOR oplist); \
|
} while (c == M_GET_SEPARATOR oplist); \
|
||||||
M_CALL_CLEAR(oplist, item); \
|
|
||||||
success = (c == ']'); \
|
success = (c == ']'); \
|
||||||
|
exit_clear: \
|
||||||
|
M_CALL_CLEAR(oplist, item); \
|
||||||
exit: \
|
exit: \
|
||||||
if (endp) *endp = str; \
|
if (endp) *endp = str; \
|
||||||
return success; \
|
return success; \
|
||||||
|
|||||||
Reference in new issue
Block a user