Merge pull request #32525 from qarmin/fix_small_memory_leak_PackedSourcePCK
Fix small memory leak in PackedSourcePCK::try_open_pack
This commit is contained in:
commit
e57272987d
|
@ -151,6 +151,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
|
||||||
magic = f->get_32();
|
magic = f->get_32();
|
||||||
if (magic != 0x43504447) {
|
if (magic != 0x43504447) {
|
||||||
|
|
||||||
|
f->close();
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +163,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
|
||||||
magic = f->get_32();
|
magic = f->get_32();
|
||||||
if (magic != 0x43504447) {
|
if (magic != 0x43504447) {
|
||||||
|
|
||||||
|
f->close();
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -172,8 +174,16 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
|
||||||
uint32_t ver_minor = f->get_32();
|
uint32_t ver_minor = f->get_32();
|
||||||
f->get_32(); // ver_rev
|
f->get_32(); // ver_rev
|
||||||
|
|
||||||
ERR_FAIL_COND_V_MSG(version != PACK_VERSION, false, "Pack version unsupported: " + itos(version) + ".");
|
if (version != PACK_VERSION) {
|
||||||
ERR_FAIL_COND_V_MSG(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false, "Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + ".");
|
f->close();
|
||||||
|
memdelete(f);
|
||||||
|
ERR_FAIL_V_MSG(false, "Pack version unsupported: " + itos(version) + ".");
|
||||||
|
}
|
||||||
|
if (ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR)) {
|
||||||
|
f->close();
|
||||||
|
memdelete(f);
|
||||||
|
ERR_FAIL_V_MSG(false, "Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + ".");
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
//reserved
|
//reserved
|
||||||
|
@ -200,6 +210,8 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
|
||||||
PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5, this, p_replace_files);
|
PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5, this, p_replace_files);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
f->close();
|
||||||
|
memdelete(f);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue