Sfoglia il codice sorgente

Core: fix possible memory leaks.

Andreas Haas 8 anni fa
parent
commit
a2734df7ed
2 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 1 2
      core/io/file_access_zip.cpp
  2. 1 0
      core/io/pck_packer.cpp

+ 1 - 2
core/io/file_access_zip.cpp

@@ -149,8 +149,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
 	unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io);
 	ERR_FAIL_COND_V(!pkg, NULL);
 	int unz_err = unzGoToFilePos(pkg, &file.file_pos);
-	ERR_FAIL_COND_V(unz_err != UNZ_OK, NULL);
-	if (unzOpenCurrentFile(pkg) != UNZ_OK) {
+	if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) {
 
 		unzClose(pkg);
 		ERR_FAIL_V(NULL);

+ 1 - 0
core/io/pck_packer.cpp

@@ -172,6 +172,7 @@ Error PCKPacker::flush(bool p_verbose) {
 		printf("\n");
 
 	file->close();
+	memdelete(buf);
 
 	return OK;
 };