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

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