Merge pull request #35343 from timothyqiu/xml-leak
Fixes XMLParser leak when open multiple times
This commit is contained in:
commit
2e8d4b681e
1 changed files with 8 additions and 0 deletions
|
@ -471,6 +471,10 @@ Error XMLParser::open_buffer(const Vector<uint8_t> &p_buffer) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(p_buffer.size() == 0, ERR_INVALID_DATA);
|
ERR_FAIL_COND_V(p_buffer.size() == 0, ERR_INVALID_DATA);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
memdelete_arr(data);
|
||||||
|
}
|
||||||
|
|
||||||
length = p_buffer.size();
|
length = p_buffer.size();
|
||||||
data = memnew_arr(char, length + 1);
|
data = memnew_arr(char, length + 1);
|
||||||
copymem(data, p_buffer.ptr(), length);
|
copymem(data, p_buffer.ptr(), length);
|
||||||
|
@ -489,6 +493,10 @@ Error XMLParser::open(const String &p_path) {
|
||||||
length = file->get_len();
|
length = file->get_len();
|
||||||
ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
memdelete_arr(data);
|
||||||
|
}
|
||||||
|
|
||||||
data = memnew_arr(char, length + 1);
|
data = memnew_arr(char, length + 1);
|
||||||
file->get_buffer((uint8_t *)data, length);
|
file->get_buffer((uint8_t *)data, length);
|
||||||
data[length] = 0;
|
data[length] = 0;
|
||||||
|
|
Loading…
Reference in a new issue