Skip to content

Commit 0e3f22c

Browse files
committed
Fixed memory issues for packer and pack file data
1 parent 797ef2e commit 0e3f22c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

engine/resources/PackFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ std::shared_ptr<PackFileData> PackFile::FindData(const String& filepath)
7070
bodyDataSizeCompressed);
7171
CC_ASSERT(result == Z_OK, "Decompression failed for filepath: " + filepath);
7272

73-
return std::shared_ptr<PackFileData>(packFileData);
73+
return {packFileData, free};
7474
}
7575

7676
const std::map<String, PackFile::TocEntry*>& PackFile::GetEntries()

packer/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int main(int argc, char* argv[])
145145
static_cast<float>(bodyDataSizeUncompressed) * 100.f)),
146146
writeTotal)
147147
}
148-
free(bodyDataBufferCompressed);
148+
if (bodyDataBufferCompressed) free(bodyDataBufferCompressed);
149149

150150
outputFileStream.write(PACKER_MAGIC_NUMBER_TOC, PACKER_MAGIC_NUMBER_SIZE);
151151
writeTotal += PACKER_MAGIC_NUMBER_SIZE;

0 commit comments

Comments
 (0)