ref: 558fba599b82153f8d3df3618b8f707bdda46fbf
parent: c1707f54d0e1ac8fc69363b52a1c88bd79b66ff3
author: Sebastian Rasmussen <sebras@gmail.com>
date: Fri Jun 1 12:56:39 EDT 2018
jbig2dec: Make sure to return fatal/warnings when propagating error.
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -694,6 +694,8 @@
++table_index;
}
}
+
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "huffman table not found (%d)", index);
return NULL;
}
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -876,7 +876,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom DH huffman table not found (%d)", table_index);
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom DH huffman table not found (%d)", table_index);
}
params.SDHUFFDH = jbig2_build_huffman_table(ctx, huffman_params);
++table_index;
@@ -900,8 +900,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom DW huffman table not found (%d)", table_index);
- break;
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom DW huffman table not found (%d)", table_index);
}
params.SDHUFFDW = jbig2_build_huffman_table(ctx, huffman_params);
++table_index;
@@ -920,11 +919,10 @@
/* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom BMSIZE huffman table not found (%d)", table_index);
- } else {
- params.SDHUFFBMSIZE = jbig2_build_huffman_table(ctx, huffman_params);
- ++table_index;
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom BMSIZE huffman table not found (%d)", table_index);
}
+ params.SDHUFFBMSIZE = jbig2_build_huffman_table(ctx, huffman_params);
+ ++table_index;
} else {
/* Table B.1 */
params.SDHUFFBMSIZE = jbig2_build_huffman_table(ctx, &jbig2_huffman_params_A);
@@ -938,11 +936,10 @@
/* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom REFAGG huffman table not found (%d)", table_index);
- } else {
- params.SDHUFFAGGINST = jbig2_build_huffman_table(ctx, huffman_params);
- ++table_index;
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom REFAGG huffman table not found (%d)", table_index);
}
+ params.SDHUFFAGGINST = jbig2_build_huffman_table(ctx, huffman_params);
+ ++table_index;
} else {
/* Table B.1 */
params.SDHUFFAGGINST = jbig2_build_huffman_table(ctx, &jbig2_huffman_params_A);
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -656,7 +656,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom FS huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom FS huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFFS = jbig2_build_huffman_table(ctx, huffman_params);
@@ -686,7 +686,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom DS huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom DS huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFDS = jbig2_build_huffman_table(ctx, huffman_params);
@@ -711,7 +711,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom DT huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom DT huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFDT = jbig2_build_huffman_table(ctx, huffman_params);
@@ -733,7 +733,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom RDW huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom RDW huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFRDW = jbig2_build_huffman_table(ctx, huffman_params);
@@ -760,7 +760,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom RDH huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom RDH huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFRDH = jbig2_build_huffman_table(ctx, huffman_params);
@@ -787,7 +787,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom RDX huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom RDX huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFRDX = jbig2_build_huffman_table(ctx, huffman_params);
@@ -814,7 +814,7 @@
case 3: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom RDY huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom RDY huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFRDY = jbig2_build_huffman_table(ctx, huffman_params);
@@ -838,7 +838,7 @@
case 1: /* Custom table from referred segment */
huffman_params = jbig2_find_table(ctx, segment, table_index);
if (huffman_params == NULL) {
- code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "custom RSIZE huffman table not found (%d)", table_index);
+ code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "custom RSIZE huffman table not found (%d)", table_index);
goto cleanup1;
}
params.SBHUFFRSIZE = jbig2_build_huffman_table(ctx, huffman_params);