diff --git a/lib/zip_open.c b/lib/zip_open.c index 6b3c291f..f5bf3b0c 100644 --- a/lib/zip_open.c +++ b/lib/zip_open.c @@ -324,10 +324,12 @@ static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_off /* If the central directory doesn't start on this disk, we can't check that offset is valid. Check as much as we can instead. */ if (cd->this_disk < cd->eocd_disk) { /* Disks before the start of the central directory don't contain an EOCD. */ + _zip_cdir_free(cd); return false; } if (cd->size <= cd->eocd_offset) { /* The complete central directory would fit on this disk. */ + _zip_cdir_free(cd); return false; } } @@ -337,6 +339,7 @@ static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_off /* An empty archive doesn't contain central directory entries. */ } else if (!check_magic(cd->offset, buffer, buf_offset, za->src, CENTRAL_MAGIC)) { + _zip_cdir_free(cd); return false; } }