shithub: jbig2

Download patch

ref: a5096e4aff40b226ee4ac8519edf2615b07fe667
parent: 7a82fc0abd135e08875ec4941ba43e832bc1b7f3
author: Shailesh Mistry <shailesh.mistry@hotmail.co.uk>
date: Tue Oct 2 16:37:15 EDT 2012

Bug 693285: Apply update of original patch from zeniko. We now check that the symbol dictionary being imported is not empty. Also prevent seg faults resulting from the threadsafe update.


--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -149,7 +149,10 @@
 
     for (index = 0; index < segment->referred_to_segment_count; index++) {
         rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
-        if (rsegment && ((rsegment->flags & 63) == 0)) n_dicts++;
+        if (rsegment && ((rsegment->flags & 63) == 0) &&
+            rsegment->result &&
+            ((*((Jbig2SymbolDict *)rsegment->result)->glyphs) != NULL))
+            n_dicts++;
     }
 
     return (n_dicts);
@@ -175,7 +178,8 @@
 
     for (index = 0; index < segment->referred_to_segment_count; index++) {
         rsegment = jbig2_find_segment(ctx, segment->referred_to_segments[index]);
-        if (rsegment && ((rsegment->flags & 63) == 0)) {
+        if (rsegment && ((rsegment->flags & 63) == 0) && rsegment->result &&
+            ((*((Jbig2SymbolDict *)rsegment->result)->glyphs) != NULL)) {
             /* add this referred to symbol dictionary */
             dicts[dindex++] = (Jbig2SymbolDict *)rsegment->result;
         }
@@ -184,7 +188,7 @@
     if (dindex != n_dicts) {
         /* should never happen */
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
-            "counted %d symbol dictionaries but build a list with %d.\n",
+            "counted %d symbol dictionaries but built a list with %d.\n",
             n_dicts, dindex);
     }