[trunk] Properly handle failure to compress (remove file)
Fixes issue 323
This commit is contained in:
parent
de04302c15
commit
4bac8488df
|
@ -1789,7 +1789,7 @@ int main(int argc, char **argv) {
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
fprintf(stderr, "failed to encode image: opj_start_compress\n");
|
fprintf(stderr, "failed to encode image: opj_start_compress\n");
|
||||||
}
|
}
|
||||||
if( bUseTiles ) {
|
if( bSuccess && bUseTiles ) {
|
||||||
OPJ_BYTE *l_data;
|
OPJ_BYTE *l_data;
|
||||||
OPJ_UINT32 l_data_size = 512*512*3;
|
OPJ_UINT32 l_data_size = 512*512*3;
|
||||||
l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE));
|
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_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
|
remove(parameters.outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -972,6 +972,7 @@ int main(int argc, char **argv)
|
||||||
/* destroy the codestream index */
|
/* destroy the codestream index */
|
||||||
opj_destroy_cstr_index(&cstr_index);
|
opj_destroy_cstr_index(&cstr_index);
|
||||||
|
|
||||||
|
if(failed) remove(parameters.outfile);
|
||||||
}
|
}
|
||||||
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue