diff options
| author | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2014-04-28 07:54:33 +0000 |
|---|---|---|
| committer | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2014-04-28 07:54:33 +0000 |
| commit | 4bac8488dfc49e09eaea69bad0bee336d5e8c134 (patch) | |
| tree | 6a2883b1b3b4c5c054d86139f8e4d7b22270d67c /src/bin | |
| parent | de04302c15d0776b0e2b4a7af1eac566df15244a (diff) | |
[trunk] Properly handle failure to compress (remove file)
Fixes issue 323
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jp2/opj_compress.c | 3 | ||||
| -rw-r--r-- | src/bin/jp2/opj_decompress.c | 1 |
2 files changed, 3 insertions, 1 deletions
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; } |
