mirror of https://github.com/mgba-emu/mgba.git
VFS: Fix crash when built with minizip
This commit is contained in:
parent
d4a6844727
commit
c7fd3be736
|
@ -61,6 +61,7 @@ struct VFileZip {
|
||||||
struct VFile d;
|
struct VFile d;
|
||||||
unzFile z;
|
unzFile z;
|
||||||
void* buffer;
|
void* buffer;
|
||||||
|
size_t bufferSize;
|
||||||
size_t fileSize;
|
size_t fileSize;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -451,7 +452,9 @@ static enum VFSType _vdezType(struct VDirEntry* vde) {
|
||||||
bool _vfzClose(struct VFile* vf) {
|
bool _vfzClose(struct VFile* vf) {
|
||||||
struct VFileZip* vfz = (struct VFileZip*) vf;
|
struct VFileZip* vfz = (struct VFileZip*) vf;
|
||||||
unzCloseCurrentFile(vfz->z);
|
unzCloseCurrentFile(vfz->z);
|
||||||
free(vfz->buffer);
|
if (vfz->buffer) {
|
||||||
|
mappedMemoryFree(vfz->buffer, vfz->bufferSize);
|
||||||
|
}
|
||||||
free(vfz);
|
free(vfz);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -536,6 +539,8 @@ void* _vfzMap(struct VFile* vf, size_t size, int flags) {
|
||||||
unzOpenCurrentFile(vfz->z);
|
unzOpenCurrentFile(vfz->z);
|
||||||
vf->seek(vf, pos, SEEK_SET);
|
vf->seek(vf, pos, SEEK_SET);
|
||||||
|
|
||||||
|
vfz->bufferSize = size;
|
||||||
|
|
||||||
return vfz->buffer;
|
return vfz->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +624,7 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) {
|
||||||
struct VFileZip* vfz = malloc(sizeof(struct VFileZip));
|
struct VFileZip* vfz = malloc(sizeof(struct VFileZip));
|
||||||
vfz->z = vdz->z;
|
vfz->z = vdz->z;
|
||||||
vfz->buffer = 0;
|
vfz->buffer = 0;
|
||||||
|
vfz->bufferSize = 0;
|
||||||
vfz->fileSize = info.uncompressed_size;
|
vfz->fileSize = info.uncompressed_size;
|
||||||
|
|
||||||
vfz->d.close = _vfzClose;
|
vfz->d.close = _vfzClose;
|
||||||
|
|
Loading…
Reference in New Issue