[poppler] Branch 'xpdf303merge' - fofi/FoFiTrueType.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Thu Sep 1 09:18:41 PDT 2011


 fofi/FoFiTrueType.cc |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 0feebf5f3c9da8d7a1154456a00492a623340cec
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Thu Sep 1 18:16:59 2011 +0200

    xpdf303: Ignore any bogus entries in the table directory
    
    It's a different approach to fix the same issue we had already fixed,
    added just to make future merge easier. We were also reallocating the
    tables array, I've kept that but doing it only when the size actually
    changes.

diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index 36467f8..26017d0 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -1974,22 +1974,23 @@ void FoFiTrueType::parse() {
   }
   tables = (TrueTypeTable *)gmallocn(nTables, sizeof(TrueTypeTable));
   pos += 12;
-  int wrongTables = 0;
+  j = 0;
   for (i = 0; i < nTables; ++i) {
-    tables[i].tag = getU32BE(pos, &parsedOk);
-    tables[i].checksum = getU32BE(pos + 4, &parsedOk);
-    tables[i].offset = (int)getU32BE(pos + 8, &parsedOk);
-    tables[i].len = (int)getU32BE(pos + 12, &parsedOk);
-    if (tables[i].offset + tables[i].len < tables[i].offset ||
-	tables[i].offset + tables[i].len > len) {
-      i--;
-      wrongTables++;
-      error(errSyntaxWarning, -1, "Found a bad table definition on true type definition, trying to continue...");
+    tables[j].tag = getU32BE(pos, &parsedOk);
+    tables[j].checksum = getU32BE(pos + 4, &parsedOk);
+    tables[j].offset = (int)getU32BE(pos + 8, &parsedOk);
+    tables[j].len = (int)getU32BE(pos + 12, &parsedOk);
+    if (tables[j].offset + tables[j].len >= tables[j].offset &&
+	tables[j].offset + tables[j].len <= len) {
+      // ignore any bogus entries in the table directory
+      ++j;
     }
     pos += 16;
   }
-  nTables -= wrongTables;
-  tables = (TrueTypeTable *)greallocn_checkoverflow(tables, nTables, sizeof(TrueTypeTable));
+  if (nTables != j) {
+    nTables = j;
+    tables = (TrueTypeTable *)greallocn_checkoverflow(tables, nTables, sizeof(TrueTypeTable));
+  }
   if (!parsedOk || tables == NULL) {
     return;
   }


More information about the poppler mailing list