Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 64745 Details for
Bug 100265
app-text/gpdf: DoS from XPDF issue
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
gpdf-xpdf-font-optimize-allanonjl.dif
gpdf-xpdf-font-optimize-allanonjl.dif (text/plain), 21.90 KB, created by
John N. Laliberte (RETIRED)
on 2005-07-30 12:33:24 UTC
(
hide
)
Description:
gpdf-xpdf-font-optimize-allanonjl.dif
Filename:
MIME Type:
Creator:
John N. Laliberte (RETIRED)
Created:
2005-07-30 12:33:24 UTC
Size:
21.90 KB
patch
obsolete
>--- gpdf-2.8.3/fofi/FoFiTrueType.h 2004-05-17 14:10:42.000000000 -0400 >+++ gpdf-2.8.3.new/fofi/FoFiTrueType.h 2005-07-30 13:37:50.000000000 -0400 >@@ -35,6 +35,7 @@ > // Create a FoFiTrueType object from a file on disk. > static FoFiTrueType *load(char *fileName); > >+ FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA); > virtual ~FoFiTrueType(); > > // Return the number of cmaps defined by this font. >@@ -100,7 +101,6 @@ > > private: > >- FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA); > void cvtEncoding(char **encoding, > FoFiOutputFunc outputFunc, > void *outputStream); >diff -ru xpdf-3.00-dist/fofi/FoFiType1C.h xpdf-3.00/fofi/FoFiType1C.h >--- xpdf-3.00-dist/fofi/FoFiType1C.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/fofi/FoFiType1C.h 2004-05-10 20:11:04.972360896 +0200 >@@ -135,6 +135,7 @@ > // Create a FoFiType1C object from a file on disk. > static FoFiType1C *load(char *fileName); > >+ FoFiType1C(char *fileA, int lenA, GBool freeFileDataA); > virtual ~FoFiType1C(); > > // Return the font name. >@@ -170,7 +171,6 @@ > > private: > >- FoFiType1C(char *fileA, int lenA, GBool freeFileDataA); > void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName, > int offset, int nBytes, > Type1CIndex *subrIdx, > --- gpdf-2.8.3/splash/SplashFTFontEngine.cc 2004-05-17 14:10:51.000000000 -0400 >+++ gpdf-2.8.3.new/splash/SplashFTFontEngine.cc 2005-07-30 11:00:51.000000000 -0400 >@@ -59,37 +59,38 @@ > } > > SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > char **enc) { >- return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc); >+ return SplashFTFontFile::loadType1Font(this, idA, src, enc); > } > > SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > char **enc) { >- return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc); >+ return SplashFTFontFile::loadType1Font(this, idA, src, enc); > } > > SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile) { >+ SplashFontSrc *src) { > FoFiType1C *ff; > Gushort *cidToGIDMap; > int nCIDs; > SplashFontFile *ret; > > // check for a CFF font >- if ((ff = FoFiType1C::load(fileName))) { >+ if (src->isFile) { >+ ff = FoFiType1C::load(src->fileName->getCString()); >+ } else { >+ ff = new FoFiType1C(src->buf, src->bufLen, gFalse); >+ } >+ if (ff) { > cidToGIDMap = ff->getCIDToGIDMap(&nCIDs); > delete ff; > } else { > cidToGIDMap = NULL; > nCIDs = 0; > } >- ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile, >- cidToGIDMap, nCIDs); >+ ret = SplashFTFontFile::loadCIDFont(this, idA, src, cidToGIDMap, nCIDs); > if (!ret) { > gfree(cidToGIDMap); > } >@@ -97,10 +98,10 @@ > } > > SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > Gushort *codeToGID, > int codeToGIDLen) { >+#if 0 > FoFiTrueType *ff; > GString *tmpFileName; > FILE *tmpFile; >@@ -119,7 +120,8 @@ > fclose(tmpFile); > ret = SplashFTFontFile::loadTrueTypeFont(this, idA, > tmpFileName->getCString(), >- gTrue, codeToGID, codeToGIDLen); >+ gTrue, codeToGID, codeToGIDLen, >+ faceIndex); > if (ret) { > if (deleteFile) { > unlink(fileName); >@@ -129,6 +131,13 @@ > } > delete tmpFileName; > return ret; >+#else >+ SplashFontFile *ret; >+ ret = SplashFTFontFile::loadTrueTypeFont(this, idA, src, >+ codeToGID, codeToGIDLen, >+ faceIndex); >+ return ret; >+#endif > } > > #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H >--- gpdf-2.8.3/splash/SplashFTFontEngine.h 2004-05-17 14:10:51.000000000 -0400 >+++ gpdf-2.8.3.new/splash/SplashFTFontEngine.h 2005-07-30 11:06:30.000000000 -0400 >@@ -20,6 +20,7 @@ > > class SplashFontFile; > class SplashFontFileID; >+class SplashFontSrc; > > //------------------------------------------------------------------------ > // SplashFTFontEngine >@@ -33,15 +34,13 @@ > ~SplashFTFontEngine(); > > // Load fonts. >- SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName, >- GBool deleteFile, char **enc); >- SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName, >- GBool deleteFile, char **enc); >- SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName, >- GBool deleteFile); >- SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName, >+ SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc); >+ SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc); >+ SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src); >+ SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src, > GBool deleteFile, >- Gushort *codeToGID, int codeToGIDLen); >+ Gushort *codeToGID, int codeToGIDLeni, >+ int faceIndex=0); > > private: > >diff -ru xpdf-3.00-dist/splash/SplashFTFontFile.cc xpdf-3.00/splash/SplashFTFontFile.cc >--- xpdf-3.00-dist/splash/SplashFTFontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFTFontFile.cc 2004-05-10 20:32:37.079860584 +0200 >@@ -16,6 +16,7 @@ > #include "SplashFTFontEngine.h" > #include "SplashFTFont.h" > #include "SplashFTFontFile.h" >+#include "GString.h" > > //------------------------------------------------------------------------ > // SplashFTFontFile >@@ -23,16 +24,19 @@ > > SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, >- GBool deleteFileA, >+ SplashFontSrc *src, > char **encA) { > FT_Face faceA; > Gushort *codeToGIDA; > char *name; > int i; > >- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) { >- return NULL; >+ if (src->isFile) { >+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA)) >+ return NULL; >+ } else { >+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA)) >+ return NULL; > } > codeToGIDA = (Gushort *)gmalloc(256 * sizeof(int)); > for (i = 0; i < 256; ++i) { >@@ -42,48 +46,55 @@ > } > } > >- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA, >+ return new SplashFTFontFile(engineA, idA, src, > faceA, codeToGIDA, 256); > } > > SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, >- GBool deleteFileA, >+ SplashFontSrc *src, > Gushort *codeToGIDA, > int codeToGIDLenA) { > FT_Face faceA; > >- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) { >- return NULL; >+ if (src->isFile) { >+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA)) >+ return NULL; >+ } else { >+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA)) >+ return NULL; > } > >- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA, >+ return new SplashFTFontFile(engineA, idA, src, > faceA, codeToGIDA, codeToGIDLenA); > } > > SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, >- GBool deleteFileA, >+ SplashFontSrc *src, > Gushort *codeToGIDA, >- int codeToGIDLenA) { >+ int codeToGIDLenA, >+ int faceIndexA) { > FT_Face faceA; > >- if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) { >- return NULL; >+ if (src->isFile) { >+ if (FT_New_Face(engineA->lib, src->fileName->getCString(), faceIndexA, &faceA)) >+ return NULL; >+ } else { >+ if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, faceIndexA, &faceA)) >+ return NULL; > } > >- return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA, >+ return new SplashFTFontFile(engineA, idA, src, > faceA, codeToGIDA, codeToGIDLenA); > } > > SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *srcA, > FT_Face faceA, > Gushort *codeToGIDA, int codeToGIDLenA): >- SplashFontFile(idA, fileNameA, deleteFileA) >+ SplashFontFile(idA, srcA) > { > engine = engineA; > face = faceA; >diff -ru xpdf-3.00-dist/splash/SplashFTFontFile.h xpdf-3.00/splash/SplashFTFontFile.h >--- xpdf-3.00-dist/splash/SplashFTFontFile.h 2004-05-10 17:41:22.939474000 +0200 >+++ xpdf-3.00/splash/SplashFTFontFile.h 2004-05-10 19:32:26.463323990 +0200 >@@ -30,18 +30,18 @@ > public: > > static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA, >- SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA, char **encA); >+ SplashFontFileID *idA, >+ SplashFontSrc *src, char **encA); > static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA, >- SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA, >+ SplashFontFileID *idA, >+ SplashFontSrc *src, > Gushort *codeToCIDA, int codeToGIDLenA); > static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, >- GBool deleteFileA, >+ SplashFontSrc *src, > Gushort *codeToGIDA, >- int codeToGIDLenA); >+ int codeToGIDLenA, >+ int faceIndexA=0); > > virtual ~SplashFTFontFile(); > >@@ -53,7 +53,7 @@ > > SplashFTFontFile(SplashFTFontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *srcA, > FT_Face faceA, > Gushort *codeToGIDA, int codeToGIDLenA); >--- gpdf-2.8.3/splash/SplashFontEngine.cc 2004-05-17 14:10:52.000000000 -0400 >+++ gpdf-2.8.3.new/splash/SplashFontEngine.cc 2005-07-30 11:08:31.000000000 -0400 >@@ -105,19 +105,18 @@ > } > > SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, char **enc) { >+ SplashFontSrc *src, char **enc) { > SplashFontFile *fontFile; > > fontFile = NULL; > #if HAVE_T1LIB_H > if (!fontFile && t1Engine) { >- fontFile = t1Engine->loadType1Font(idA, fileName, deleteFile, enc); >+ fontFile = t1Engine->loadType1Font(idA, src, enc); > } > #endif > #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H > if (!fontFile && ftEngine) { >- fontFile = ftEngine->loadType1Font(idA, fileName, deleteFile, enc); >+ fontFile = ftEngine->loadType1Font(idA, src, enc); > } > #endif > >@@ -125,28 +124,25 @@ > // semantics, this will remove the last link; otherwise it will > // return an error, leaving the file to be deleted later (if > // loadXYZFont failed, the file will always be deleted) >- if (deleteFile) { >- unlink(fontFile ? fontFile->fileName->getCString() : fileName); >- } >+ src->unref(); > > return fontFile; > } > > SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > char **enc) { > SplashFontFile *fontFile; > > fontFile = NULL; > #if HAVE_T1LIB_H > if (!fontFile && t1Engine) { >- fontFile = t1Engine->loadType1CFont(idA, fileName, deleteFile, enc); >+ fontFile = t1Engine->loadType1CFont(idA, src, enc); > } > #endif > #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H > if (!fontFile && ftEngine) { >- fontFile = ftEngine->loadType1CFont(idA, fileName, deleteFile, enc); >+ fontFile = ftEngine->loadType1CFont(idA, src, enc); > } > #endif > >@@ -154,22 +150,19 @@ > // semantics, this will remove the last link; otherwise it will > // return an error, leaving the file to be deleted later (if > // loadXYZFont failed, the file will always be deleted) >- if (deleteFile) { >- unlink(fontFile ? fontFile->fileName->getCString() : fileName); >- } >+ src->unref(); > > return fontFile; > } > > SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile) { >+ SplashFontSrc *src) { > SplashFontFile *fontFile; > > fontFile = NULL; > #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H > if (!fontFile && ftEngine) { >- fontFile = ftEngine->loadCIDFont(idA, fileName, deleteFile); >+ fontFile = ftEngine->loadCIDFont(idA, src); > } > #endif > >@@ -177,16 +170,13 @@ > // semantics, this will remove the last link; otherwise it will > // return an error, leaving the file to be deleted later (if > // loadXYZFont failed, the file will always be deleted) >- if (deleteFile) { >- unlink(fontFile ? fontFile->fileName->getCString() : fileName); >- } >+ src->unref(); > > return fontFile; > } > > SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > Gushort *codeToGID, > int codeToGIDLen) { > SplashFontFile *fontFile; >@@ -194,7 +184,7 @@ > fontFile = NULL; > #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H > if (!fontFile && ftEngine) { >- fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile, >+ fontFile = ftEngine->loadTrueTypeFont(idA, src, > codeToGID, codeToGIDLen); > } > #endif >@@ -207,9 +197,7 @@ > // semantics, this will remove the last link; otherwise it will > // return an error, leaving the file to be deleted later (if > // loadXYZFont failed, the file will always be deleted) >- if (deleteFile) { >- unlink(fontFile ? fontFile->fileName->getCString() : fileName); >- } >+ src->unref(); > > return fontFile; > } >--- gpdf-2.8.3/splash/SplashFontEngine.h 2004-05-17 14:10:52.000000000 -0400 >+++ gpdf-2.8.3.new/splash/SplashFontEngine.h 2005-07-30 13:53:03.000000000 -0400 >@@ -21,6 +21,7 @@ > class SplashFontFile; > class SplashFontFileID; > class SplashFont; >+class SplashFontSrc; > > //------------------------------------------------------------------------ > >@@ -50,14 +51,10 @@ > SplashFontFile *getFontFile(SplashFontFileID *id); > > // Load fonts - these create new SplashFontFile objects. >- SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName, >- GBool deleteFile, char **enc); >- SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName, >- GBool deleteFile, char **enc); >- SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName, >- GBool deleteFile); >- SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName, >- GBool deleteFile, >+ SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, char **enc); >+ SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, char **enc); >+ SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src); >+ SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src, > Gushort *codeToGID, int codeToGIDLen); > > // Get a font - this does a cache lookup first, and if not found, > >diff -ru xpdf-3.00-dist/splash/SplashFontFile.cc xpdf-3.00/splash/SplashFontFile.cc >--- xpdf-3.00-dist/splash/SplashFontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFontFile.cc 2004-05-10 20:41:01.232292315 +0200 >@@ -17,6 +17,7 @@ > #include "GString.h" > #include "SplashFontFile.h" > #include "SplashFontFileID.h" >+#include "gmem.h" > > #ifdef VMS > #if (__VMS_VER < 70000000) >@@ -28,19 +29,15 @@ > // SplashFontFile > //------------------------------------------------------------------------ > >-SplashFontFile::SplashFontFile(SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA) { >+SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) { > id = idA; >- fileName = new GString(fileNameA); >- deleteFile = deleteFileA; >+ src = srcA; >+ src->ref(); > refCnt = 0; > } > > SplashFontFile::~SplashFontFile() { >- if (deleteFile) { >- unlink(fileName->getCString()); >- } >- delete fileName; >+ src->unref(); > delete id; > } > >@@ -53,3 +50,60 @@ > delete this; > } > } >+ >+// >+ >+SplashFontSrc::SplashFontSrc() { >+ isFile = gFalse; >+ deleteSrc = gFalse; >+ fileName = NULL; >+ buf = NULL; >+ refcnt = 1; >+} >+ >+SplashFontSrc::~SplashFontSrc() { >+ if (deleteSrc) { >+ if (isFile) { >+ if (fileName) >+ unlink(fileName->getCString()); >+ } else { >+ if (buf) >+ gfree(buf); >+ } >+ } >+ >+ if (isFile && fileName) >+ delete fileName; >+} >+ >+void SplashFontSrc::ref() { >+ refcnt++; >+} >+ >+void SplashFontSrc::unref() { >+ if (! --refcnt) >+ delete this; >+} >+ >+void SplashFontSrc::setFile(GString *file, GBool del) >+{ >+ isFile = gTrue; >+ fileName = file->copy(); >+ deleteSrc = del; >+} >+ >+void SplashFontSrc::setFile(const char *file, GBool del) >+{ >+ isFile = gTrue; >+ fileName = new GString(file); >+ deleteSrc = del; >+} >+ >+void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del) >+{ >+ isFile = gFalse; >+ buf = bufA; >+ bufLen = bufLenA; >+ deleteSrc = del; >+} >+ >diff -ru xpdf-3.00-dist/splash/SplashFontFile.h xpdf-3.00/splash/SplashFontFile.h >--- xpdf-3.00-dist/splash/SplashFontFile.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashFontFile.h 2004-05-10 20:08:31.770168702 +0200 >@@ -25,6 +25,25 @@ > // SplashFontFile > //------------------------------------------------------------------------ > >+struct SplashFontSrc { >+ SplashFontSrc(); >+ ~SplashFontSrc(); >+ >+ void setFile(GString *file, GBool del); >+ void setFile(const char *file, GBool del); >+ void setBuf(char *bufA, int buflenA, GBool del); >+ >+ void ref(); >+ void unref(); >+ >+ GBool isFile; >+ GString *fileName; >+ char *buf; >+ int bufLen; >+ GBool deleteSrc; >+ int refcnt; >+}; >+ > class SplashFontFile { > public: > >@@ -46,12 +65,10 @@ > > protected: > >- SplashFontFile(SplashFontFileID *idA, char *fileNameA, >- GBool deleteFileA); >+ SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA); > > SplashFontFileID *id; >- GString *fileName; >- GBool deleteFile; >+ SplashFontSrc *src; > int refCnt; > > friend class SplashFontEngine; >diff -ru xpdf-3.00-dist/splash/SplashT1FontEngine.cc xpdf-3.00/splash/SplashT1FontEngine.cc >--- xpdf-3.00-dist/splash/SplashT1FontEngine.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontEngine.cc 2004-05-10 19:57:05.300244166 +0200 >@@ -82,24 +82,26 @@ > } > > SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > char **enc) { >- return SplashT1FontFile::loadType1Font(this, idA, fileName, deleteFile, enc); >+ return SplashT1FontFile::loadType1Font(this, idA, src, enc); > } > > SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA, >- char *fileName, >- GBool deleteFile, >+ SplashFontSrc *src, > char **enc) { > FoFiType1C *ff; > GString *tmpFileName; > FILE *tmpFile; > SplashFontFile *ret; >+ SplashFontSrc *newsrc; > >- if (!(ff = FoFiType1C::load(fileName))) { >+ if (src->isFile) >+ ff = FoFiType1C::load(src->fileName); >+ else >+ ff = new FoFiType1C(src->buf, src->bufLen, gFalse); >+ if (! ff) > return NULL; >- } > tmpFileName = NULL; > if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) { > delete ff; >@@ -108,16 +110,11 @@ > ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile); > delete ff; > fclose(tmpFile); >- ret = SplashT1FontFile::loadType1Font(this, idA, tmpFileName->getCString(), >- gTrue, enc); >- if (ret) { >- if (deleteFile) { >- unlink(fileName); >- } >- } else { >- unlink(tmpFileName->getCString()); >- } >+ newsrc = new SplashFontSrc; >+ newsrc->setFile(tmpFileName, gTrue); > delete tmpFileName; >+ ret = SplashT1FontFile::loadType1Font(this, idA, newsrc, enc); >+ newsrc->unref(); > return ret; > } > >diff -ru xpdf-3.00-dist/splash/SplashT1FontFile.cc xpdf-3.00/splash/SplashT1FontFile.cc >--- xpdf-3.00-dist/splash/SplashT1FontFile.cc 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontFile.cc 2004-05-10 20:37:08.106264053 +0200 >@@ -25,8 +25,7 @@ > > SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, >- GBool deleteFileA, >+ SplashFontSrc *src, > char **encA) { > int t1libIDA; > char **encTmp; >@@ -34,9 +33,27 @@ > int encStrSize; > char *encPtr; > int i; >- >+ GString *fileNameA; >+ SplashFontSrc *newsrc = NULL; >+ SplashFontFile *ff; >+ >+ if (! src->isFile) { >+ GString *tmpFileName; >+ FILE *tmpFile; >+ if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) >+ return NULL; >+ fwrite(src->buf, 1, src->bufLen, tmpFile); >+ fclose(tmpFile); >+ newsrc = new SplashFontSrc; >+ newsrc->setFile(tmpFileName, gTrue); >+ src = newsrc; >+ delete tmpFileName; >+ } >+ fileNameA = src->fileName; > // load the font file > if ((t1libIDA = T1_AddFont(fileNameA)) < 0) { >+ if (newsrc) >+ delete newsrc; > return NULL; > } > T1_LoadFont(t1libIDA); >@@ -63,15 +80,18 @@ > encTmp[256] = "custom"; > T1_ReencodeFont(t1libIDA, encTmp); > >- return new SplashT1FontFile(engineA, idA, fileNameA, deleteFileA, >+ ff = new SplashT1FontFile(engineA, idA, src, > t1libIDA, encTmp, encStrTmp); >+ if (newsrc) >+ newsrc->unref(); >+ return ff; > } > > SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *srcA, > int t1libIDA, char **encA, char *encStrA): >- SplashFontFile(idA, fileNameA, deleteFileA) >+ SplashFontFile(idA, srcA) > { > engine = engineA; > t1libID = t1libIDA; >diff -ru xpdf-3.00-dist/splash/SplashT1FontFile.h xpdf-3.00/splash/SplashT1FontFile.h >--- xpdf-3.00-dist/splash/SplashT1FontFile.h 2004-01-22 02:26:44.000000000 +0100 >+++ xpdf-3.00/splash/SplashT1FontFile.h 2004-05-10 19:39:07.153270918 +0200 >@@ -28,7 +28,7 @@ > > static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *src, > char **encA); > > virtual ~SplashT1FontFile(); >@@ -41,7 +41,7 @@ > > SplashT1FontFile(SplashT1FontEngine *engineA, > SplashFontFileID *idA, >- char *fileNameA, GBool deleteFileA, >+ SplashFontSrc *src, > int t1libIDA, char **encA, char *encStrA); > > SplashT1FontEngine *engine; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 100265
:
64745
|
65732