Blame SOURCES/fontforge-20120731-pdf-bounds.patch

dc872b
--- fontforge-20120731-b/fontforge/parsepdf.c	2012-08-02 16:09:09.000000000 +0100
dc872b
+++ fontforge-20120731-b-new/fontforge/parsepdf.c	2013-02-07 17:44:05.371466086 +0000
dc872b
@@ -1691,9 +1691,9 @@
dc872b
     /* to "Unicode" values it specifies rather than to the real order in which the glyphs are */
dc872b
     /* stored in the file */
dc872b
     pos = cmap_from_cid || sf->map == NULL ? gid : sf->map->map[gid];
dc872b
-    sc = sf->glyphs[pos];
dc872b
     
dc872b
-    if (pos >= 0 && pos < sf->glyphcnt && (sc->unicodeenc != uvals[0] || nuni > 1)) {
dc872b
+    if (pos >= 0 && pos < sf->glyphcnt && (sf->glyphs[pos]->unicodeenc != uvals[0] || nuni > 1)) {
dc872b
+	sc = sf->glyphs[pos];
dc872b
 	/* Sometimes FF instead of assigning proper Unicode values to TTF glyphs keeps */
dc872b
 	/* them encoded to the same codepoint, but creates for each glyph an alternate */
dc872b
 	/* encoding, corresponding to the position this glyph has in the font's encoding */
dc872b
@@ -1723,6 +1723,7 @@
dc872b
     FILE *file;
dc872b
     int i, j, gid, start, end, uni, cur=0, nuni, nhex, nchars, lo, *uvals;
dc872b
     long *mappings;
dc872b
+    size_t num_mappings;
dc872b
     char tok[200], *ccval, prevtok[200];
dc872b
     SplineFont *sf = basesf->subfontcnt > 0 ? basesf->subfonts[0] : basesf;
dc872b
 
dc872b
@@ -1733,9 +1734,14 @@
dc872b
 return;
dc872b
     rewind(file);
dc872b
     
dc872b
+    num_mappings = sf->glyphcnt;
dc872b
     mappings = gcalloc(sf->glyphcnt,sizeof(long));
dc872b
     while ( pdf_getprotectedtok(file,tok) >= 0 ) {
dc872b
 	if ( strcmp(tok,"beginbfchar") == 0 && sscanf(prevtok,"%d",&nchars)) {
dc872b
+	    if (cur + nchars >= num_mappings) {
dc872b
+		num_mappings = cur + nchars;
dc872b
+		mappings = grealloc(mappings, num_mappings * sizeof(long));
dc872b
+	    }
dc872b
 	    for (i=0; i
dc872b
 		if (pdf_skip_brackets(file,tok) >= 0 && sscanf(tok,"%x",&gid) &&
dc872b
 		    pdf_skip_brackets(file,tok) >= 0 && sscanf(tok,"%lx",&mappings[cur])) {