commit 1cb36a166e2391d54e0f976c6aaa86352b9973bb Author: Tomas Hoger Date: Wed Oct 14 15:33:40 2009 +0200 Add missing readEmbFontFile return value checks If omitted, NULL deref crashes may occur diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc index 0866d88..8a2a059 100644 --- a/poppler/GfxFont.cc +++ b/poppler/GfxFont.cc @@ -704,8 +704,9 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GooString *nameA, if (extFontFile) { ffT1 = FoFiType1::load(extFontFile->getCString()); } else { - buf = readEmbFontFile(xref, &len); - ffT1 = FoFiType1::make(buf, len); + if ((buf = readEmbFontFile(xref, &len))) { + ffT1 = FoFiType1::make(buf, len); + } } if (ffT1) { if (ffT1->getName()) { @@ -723,8 +724,9 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GooString *nameA, if (extFontFile) { ffT1C = FoFiType1C::load(extFontFile->getCString()); } else { - buf = readEmbFontFile(xref, &len); - ffT1C = FoFiType1C::make(buf, len); + if ((buf = readEmbFontFile(xref, &len))) { + ffT1C = FoFiType1C::make(buf, len); + } } if (ffT1C) { if (ffT1C->getName()) { diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 9967892..722be31 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -2112,7 +2112,7 @@ void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, // convert it to a Type 1 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { + if (fontBuf && (ffT1C = FoFiType1C::make(fontBuf, fontLen))) { ffT1C->convertToType1(psName->getCString(), NULL, gTrue, outputFunc, outputStream); delete ffT1C; @@ -2152,7 +2152,7 @@ void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, // convert it to a Type 1 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (fontBuf && (ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (ffTT->isOpenTypeCFF()) { ffTT->convertToType1(psName->getCString(), NULL, gTrue, outputFunc, outputStream); @@ -2199,7 +2199,7 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, // convert it to a Type 42 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (fontBuf && (ffTT = FoFiTrueType::make(fontBuf, fontLen))) { codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); ffTT->convertToType42(psName->getCString(), ((Gfx8BitFont *)font)->getHasEncoding() @@ -2396,7 +2396,7 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { + if (fontBuf && (ffT1C = FoFiType1C::make(fontBuf, fontLen))) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffT1C->convertToCIDType0(psName->getCString(), outputFunc, outputStream); @@ -2444,7 +2444,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (fontBuf && (ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffTT->convertToCIDType2(psName->getCString(), @@ -2497,7 +2497,7 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); - if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { + if (fontBuf && (ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (ffTT->isOpenTypeCFF()) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font