diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-04-06 00:41:01 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-04-11 11:45:12 +0800 |
commit | 2b2dcf4ccf401ed210f03c858b304994749fd2b3 (patch) | |
tree | ee354a8558b2d294ec8013ca55cf8ff785481cb1 /jbig2dec/jbig2_arith.c | |
parent | 7ede8fc2b5e8498619d1e32b6b7fbbf9f926a055 (diff) | |
download | ghostpdl-2b2dcf4ccf401ed210f03c858b304994749fd2b3.tar.gz |
jbig2dec: Improve error handling.
Some functions detected errors but would not return these
to the caller. These functions may now indicate errors:
jbig2_arith_decode(), jbig2_image_resize()
Errors detected by following functions were not always
handled, but they are now handled properly:
jbig2_arith_decode(), jbig2_arith_iaid_decode()
jbig2_arith_int_ctx_new(), jbig2_build_huffman_table()
jbig2_complete_page(), jbig2_image_compose()
jbig2_decode_refinement_region(), jbig2_ctx_new()
jbig2_image_resize(), jbig2_image_write_pbm()
jbig2_image_write_pbm_file(), jbig2_image_write_png()
jbig2_image_write_png_file(), jbig2_metadata_add()
jbig2_page_add_result(), jbig2_renew()
jbig2_strndup()
Some functions detected errors but did not fail early enough:
jbig2_decode_pattern_dict(), jbig2_decode_halftone_region()
jbig2_decode_mmr_line() detected errors but did not produce
suitable error messages. This has been rectified.
Finally, if a subfunction indicates an error by returning an
error code, the calling function will report a warning and
return, indicating failure.
Diffstat (limited to 'jbig2dec/jbig2_arith.c')
-rw-r--r-- | jbig2dec/jbig2_arith.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/jbig2dec/jbig2_arith.c b/jbig2dec/jbig2_arith.c index 7567ba1e8..52cc3dbbd 100644 --- a/jbig2dec/jbig2_arith.c +++ b/jbig2dec/jbig2_arith.c @@ -263,7 +263,7 @@ jbig2_arith_renormd(Jbig2ArithState *as) } bool -jbig2_arith_decode(Jbig2ArithState *as, Jbig2ArithCx *pcx) +jbig2_arith_decode(Jbig2ArithState *as, Jbig2ArithCx *pcx, int *code) { Jbig2ArithCx cx = *pcx; const Jbig2ArithQe *pqe; @@ -271,7 +271,8 @@ jbig2_arith_decode(Jbig2ArithState *as, Jbig2ArithCx *pcx) bool D; if (index >= MAX_QE_ARRAY_SIZE) { - return -1; + *code = -1; + return 0; } else { pqe = &jbig2_arith_Qe[index]; } @@ -354,6 +355,7 @@ main(int argc, char **argv) Jbig2ArithState *as; int i; Jbig2ArithCx cx = 0; + int code; ctx = jbig2_ctx_new(NULL, 0, NULL, NULL, NULL); @@ -369,7 +371,7 @@ main(int argc, char **argv) #else (void) #endif - jbig2_arith_decode(as, &cx); + jbig2_arith_decode(as, &cx, &code); #ifdef JBIG2_DEBUG_ARITH fprintf(stderr, "%3d: D = %d, ", i, D); |