[poppler] Problem with your patch
Koji Otani
sho at bbr.jp
Wed Dec 19 21:36:55 PST 2007
Hi
I found 2 problems.
(1) bad location of memory allocation code.
and use null pointer.
This causes crash.
(2) But, getCodeToGIDMap function is called by the unexpected situation.
In test PDF File (getticket.pdf), fonts are embedded and CIDToGIDMap
entry is not contained. PDF specification sayes that if the TrueType font
program is embedded, the Type 2 CIDFont dictionary must contain a
CIDToGIDMap entry. (see PDF Reference, version 1.7 page 438).
So, when a font is embedded, getCodeToGIDMap need not be called
because cidToGID map is already set. but if CIDToGIDMap entry is
'identity' or not contained, getCodeToGIDMap is called and returnes
incorrect cidToGID map.
There has been problem(2) since poppler version 0.5.4 (before my
patches were applied.)
I attached patch resolves these problems.
(1) moved the allocation code to correct location.
(2) When a font is embedded, getCodeToGIDMap returnes cidToGID map
is already set.
This patch also removed unused variables.
Please apply this patch.
Thanks,
---------
Koji Otani
From: Albert Astals Cid <aacid at kde.org>
Subject: Problem with your patch
Date: Wed, 19 Dec 2007 21:18:16 +0100
Message-ID: <200712192118.17083.aacid at kde.org>
aacid> Hi Koji, when using poppler head with your latest patches, i get a crash in
aacid> http://bugs.freedesktop.org/attachment.cgi?id=13226
aacid>
aacid> Could you please have a look?
aacid>
aacid> I'm attaching the gdb backtrace.
aacid>
aacid> Albert
-------------- next part --------------
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 9a573fe..044e256 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1802,8 +1802,6 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
int wmode;
char **cmapName;
CMap *cMap;
- int nUsed;
- Unicode u;
CMapListEntry *lp;
int cmap;
int cmapPlatform, cmapEncoding;
@@ -1811,6 +1809,14 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
*mapsizep = 0;
if (!ctu) return NULL;
if (getCollection()->cmp("Adobe-Identity") == 0) return NULL;
+ if (getEmbeddedFontName() != NULL) {
+ /* if this font is embedded font,
+ * CIDToGIDMap should be embedded in PDF file
+ * and already set. So return it.
+ */
+ *mapsizep = getCIDToGIDLen();
+ return getCIDToGID();
+ }
/* we use only unicode cmap */
cmap = -1;
@@ -1840,6 +1846,8 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
}
n = 65536;
tumap = new Unicode[n];
+ humap = new Unicode[n*N_UCS_CANDIDATES];
+ memset(humap,0,sizeof(Unicode)*n*N_UCS_CANDIDATES);
if (lp->collection != 0) {
CharCodeToUnicode *tctu;
GooString tname(lp->toUnicodeMap);
@@ -1860,8 +1868,6 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
}
delete tctu;
}
- humap = new Unicode[n*N_UCS_CANDIDATES];
- memset(humap,0,sizeof(Unicode)*n*N_UCS_CANDIDATES);
vumap = new Unicode[n];
memset(vumap,0,sizeof(Unicode)*n);
for (cmapName = lp->CMaps;*cmapName != 0;cmapName++) {
More information about the poppler
mailing list