ref: d474e9e990c9630076fc003691092017aac24326
parent: 652011d10a8d33b92bd81b933261e3cdabd09256
author: Sebastian Rasmussen <sebras@gmail.com>
date: Wed May 23 23:23:25 EDT 2018
jbig2dec: Detect NULL image pointer before trying to take reference. Attempting to take a reference to NULL is a no-op anyway.
--- a/jbig2_refinement.c
+++ b/jbig2_refinement.c
@@ -459,9 +459,9 @@
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "found reference bitmap in segment %d", ref->number);
} else {
/* the reference is just (a subset of) the page buffer */
+ if (ctx->pages[ctx->current_page].image == NULL)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "reference page bitmap has no decoded image");
params.reference = jbig2_image_reference(ctx, ctx->pages[ctx->current_page].image);
- if (params.reference == NULL)
- return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "could not take reference to reference bitmap");
/* TODO: subset the image if appropriate */
}
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -316,12 +316,12 @@
index = 0;
while (id >= dicts[index]->n_symbols)
id -= dicts[index++]->n_symbols;
- IB = jbig2_image_reference(ctx, dicts[index]->glyphs[id]);
/* SumatraPDF: fail on missing glyphs */
- if (!IB) {
+ if (dicts[index]->glyphs[id] == NULL) {
code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "missing glyph %d/%d", index, id);
goto cleanup2;
}
+ IB = jbig2_image_reference(ctx, dicts[index]->glyphs[id]);
}
if (params->SBREFINE) {
if (params->SBHUFF) {