Skip to content

Commit

Permalink
Fix resource leak.
Browse files Browse the repository at this point in the history
Coverity CID 1618309.
  • Loading branch information
0-wiz-0 committed Aug 26, 2024
1 parent b10d82b commit 6c56524
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/zip_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 6c56524

Please sign in to comment.