mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
I think this should fix the access to already-freed memory
Also drop the reference to the JSON parser when disconnecting a JSON object from the parse tree.
This commit is contained in:
parent
681907e88d
commit
86ff221663
@ -708,6 +708,21 @@ void json_free(json_object *o) {
|
|||||||
free(o);
|
free(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void json_disconnect_parser(json_object *o) {
|
||||||
|
if (o->type == JSON_HASH) {
|
||||||
|
for (size_t i = 0; i < o->length; i++) {
|
||||||
|
json_disconnect_parser(o->keys[i]);
|
||||||
|
json_disconnect_parser(o->values[i]);
|
||||||
|
}
|
||||||
|
} else if (o->type == JSON_ARRAY) {
|
||||||
|
for (size_t i = 0; i < o->length; i++) {
|
||||||
|
json_disconnect_parser(o->array[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
o->parser = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void json_disconnect(json_object *o) {
|
void json_disconnect(json_object *o) {
|
||||||
// Expunge references to this as an array element
|
// Expunge references to this as an array element
|
||||||
// or a hash key or value.
|
// or a hash key or value.
|
||||||
@ -761,6 +776,7 @@ void json_disconnect(json_object *o) {
|
|||||||
o->parser->root = NULL;
|
o->parser->root = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_disconnect_parser(o);
|
||||||
o->parent = NULL;
|
o->parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user