mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[cpp] Change traversal order of Json::~Json(). Old order would grow stack much more than needed, leading to crashes when freeing big Json trees.
This commit is contained in:
parent
d2da9e795c
commit
479c236835
@ -120,17 +120,23 @@ Json::Json(const char *value) :
|
||||
}
|
||||
|
||||
Json::~Json() {
|
||||
delete _child;
|
||||
spine::Json* curr = nullptr;
|
||||
spine::Json* next = _child;
|
||||
do {
|
||||
curr = next;
|
||||
if (curr) {
|
||||
next = curr->_next;
|
||||
}
|
||||
delete curr;
|
||||
} while(next);
|
||||
|
||||
if (_valueString) {
|
||||
SpineExtension::free(_valueString, __FILE__, __LINE__);
|
||||
}
|
||||
if (_valueString) {
|
||||
SpineExtension::free(_valueString, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (_name) {
|
||||
SpineExtension::free(_name, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
delete _next;
|
||||
if (_name) {
|
||||
SpineExtension::free(_name, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
const char *Json::skip(const char *inValue) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user