diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c index 41959e20..f0ff3e4d 100644 --- a/src/bin/jp2/opj_compress.c +++ b/src/bin/jp2/opj_compress.c @@ -1789,7 +1789,7 @@ int main(int argc, char **argv) { if (!bSuccess) { fprintf(stderr, "failed to encode image: opj_start_compress\n"); } - if( bUseTiles ) { + if( bSuccess && bUseTiles ) { OPJ_BYTE *l_data; OPJ_UINT32 l_data_size = 512*512*3; l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE)); @@ -1822,6 +1822,7 @@ int main(int argc, char **argv) { opj_destroy_codec(l_codec); opj_image_destroy(image); fprintf(stderr, "failed to encode image\n"); + remove(parameters.outfile); return 1; } diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 1362a1bc..3bcf947f 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -972,6 +972,7 @@ int main(int argc, char **argv) /* destroy the codestream index */ opj_destroy_cstr_index(&cstr_index); + if(failed) remove(parameters.outfile); } return failed ? EXIT_FAILURE : EXIT_SUCCESS; }