Skip to content

Commit

Permalink
FIXUP fixed double free issue.
Browse files Browse the repository at this point in the history
Calls to zip_stream_close free the buffer provided in zip_stream_open.
Because of all of the internal reallocs that may happen on the buffer
passed to zip_stream_open, I think the cleanest flow is that the user
expects zip_stream_open to take management of their buffer and then
get the updated zip via zip_stream_copy as a new buffer.
  • Loading branch information
prot0man committed Jan 16, 2024
1 parent cde8a58 commit 2dfe454
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/test_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ MU_TEST(test_entries_delete_stream) {
zip_stream_copy(zip, (void **)&modified_zdata, &zsize);
mu_check(modified_zdata != NULL);

// Note that zip_stream_close will free the zdata passed in zip_stream_open
zip_stream_close(zip);
free(zdata);
zdata = NULL;

zip = zip_stream_open(modified_zdata, zsize, 0, 'r');
Expand Down

0 comments on commit 2dfe454

Please sign in to comment.