7z: Make error handling a little more robust.
This commit is contained in:
parent
00599b7dac
commit
22297e7ea2
|
@ -285,12 +285,15 @@ static PHYSFS_Io *SZIP_openRead(void *opaque, const char *path)
|
||||||
&blockIndex, &outBuffer, &outBufferSize, &offset,
|
&blockIndex, &outBuffer, &outBufferSize, &offset,
|
||||||
&outSizeProcessed, alloc, alloc);
|
&outSizeProcessed, alloc, alloc);
|
||||||
GOTO_IF(rc != SZ_OK, szipErrorCode(rc), SZIP_openRead_failed);
|
GOTO_IF(rc != SZ_OK, szipErrorCode(rc), SZIP_openRead_failed);
|
||||||
|
GOTO_IF(outBuffer == NULL, PHYSFS_ERR_OUT_OF_MEMORY, SZIP_openRead_failed);
|
||||||
|
|
||||||
io->destroy(io);
|
io->destroy(io);
|
||||||
io = NULL;
|
io = NULL;
|
||||||
|
|
||||||
buf = allocator.Malloc(outSizeProcessed);
|
buf = allocator.Malloc(outSizeProcessed ? outSizeProcessed : 1);
|
||||||
GOTO_IF(buf == NULL, PHYSFS_ERR_OUT_OF_MEMORY, SZIP_openRead_failed);
|
GOTO_IF(buf == NULL, PHYSFS_ERR_OUT_OF_MEMORY, SZIP_openRead_failed);
|
||||||
|
|
||||||
|
if (outSizeProcessed > 0)
|
||||||
memcpy(buf, outBuffer + offset, outSizeProcessed);
|
memcpy(buf, outBuffer + offset, outSizeProcessed);
|
||||||
|
|
||||||
alloc->Free(alloc, outBuffer);
|
alloc->Free(alloc, outBuffer);
|
||||||
|
|
Loading…
Reference in New Issue