Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
7z: Make error handling a little more robust.
  • Loading branch information
icculus committed May 17, 2020
1 parent 00599b7 commit 22297e7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/physfs_archiver_7z.c
Expand Up @@ -285,13 +285,16 @@ static PHYSFS_Io *SZIP_openRead(void *opaque, const char *path)
&blockIndex, &outBuffer, &outBufferSize, &offset,
&outSizeProcessed, alloc, alloc);
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 = NULL;

buf = allocator.Malloc(outSizeProcessed);
buf = allocator.Malloc(outSizeProcessed ? outSizeProcessed : 1);
GOTO_IF(buf == NULL, PHYSFS_ERR_OUT_OF_MEMORY, SZIP_openRead_failed);
memcpy(buf, outBuffer + offset, outSizeProcessed);

if (outSizeProcessed > 0)
memcpy(buf, outBuffer + offset, outSizeProcessed);

alloc->Free(alloc, outBuffer);
outBuffer = NULL;
Expand Down

0 comments on commit 22297e7

Please sign in to comment.