Skip to content

Commit

Permalink
opj_compress: fix memory leak in error code path (when cannot create …
Browse files Browse the repository at this point in the history
…output file)

Fixes #1567
  • Loading branch information
rouault committed Dec 6, 2024
1 parent 1650ff9 commit ebbd7a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,9 @@ int main(int argc, char **argv)
/* open a byte stream for writing and allocate memory for all tiles */
l_stream = opj_stream_create_default_file_stream(parameters.outfile, OPJ_FALSE);
if (! l_stream) {
fprintf(stderr, "cannot create %s\n", parameters.outfile);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
ret = 1;
goto fin;
}
Expand All @@ -2263,6 +2266,9 @@ int main(int argc, char **argv)
OPJ_UINT32 l_data_size = 512 * 512 * 3;
l_data = (OPJ_BYTE*) calloc(1, l_data_size);
if (l_data == NULL) {
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
ret = 1;
goto fin;
}
Expand Down

0 comments on commit ebbd7a1

Please sign in to comment.