Merge pull request #35345 from timothyqiu/pck-packer-leak

Fixes leak when calling PCKPacker::pck_start multiple times
This commit is contained in:
Rémi Verschelde 2020-01-20 07:00:11 +01:00 committed by GitHub
commit 11260fb87f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,10 @@ void PCKPacker::_bind_methods() {
Error PCKPacker::pck_start(const String &p_file, int p_alignment) { Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
if (file != NULL) {
memdelete(file);
}
file = FileAccess::open(p_file, FileAccess::WRITE); file = FileAccess::open(p_file, FileAccess::WRITE);
ERR_FAIL_COND_V_MSG(!file, ERR_CANT_CREATE, "Can't open file to write: " + String(p_file) + "."); ERR_FAIL_COND_V_MSG(!file, ERR_CANT_CREATE, "Can't open file to write: " + String(p_file) + ".");