all repos — mgba @ c7fd3be736f3b1452e5fc69e282893cef0eaa076

mGBA Game Boy Advance Emulator

VFS: Fix crash when built with minizip
Cameron Cawley ccawley2011@gmail.com
Wed, 07 Feb 2018 23:37:50 +0000
commit

c7fd3be736f3b1452e5fc69e282893cef0eaa076

parent

d4a6844727c9b673dc1980ab01d4dabcdfe739ec

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/util/vfs/vfs-zip.csrc/util/vfs/vfs-zip.c

@@ -61,6 +61,7 @@ struct VFileZip {

struct VFile d; unzFile z; void* buffer; + size_t bufferSize; size_t fileSize; }; #endif

@@ -451,7 +452,9 @@ #else

bool _vfzClose(struct VFile* vf) { struct VFileZip* vfz = (struct VFileZip*) vf; unzCloseCurrentFile(vfz->z); - free(vfz->buffer); + if (vfz->buffer) { + mappedMemoryFree(vfz->buffer, vfz->bufferSize); + } free(vfz); return true; }

@@ -536,6 +539,8 @@ unzCloseCurrentFile(vfz->z);

unzOpenCurrentFile(vfz->z); vf->seek(vf, pos, SEEK_SET); + vfz->bufferSize = size; + return vfz->buffer; }

@@ -619,6 +624,7 @@

struct VFileZip* vfz = malloc(sizeof(struct VFileZip)); vfz->z = vdz->z; vfz->buffer = 0; + vfz->bufferSize = 0; vfz->fileSize = info.uncompressed_size; vfz->d.close = _vfzClose;