poppler/GfxFont.h          |   11 +++++++++++
 poppler/SplashOutputDev.cc |   15 ++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit a82e338b4f9639aced3201bf7639bbdf1a7974e2
Author: Albert Astals Cid <[email protected]>
Date:   Sun Sep 27 15:41:27 2015 +0200

    Fix memory leak on font reload

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 5275143..6d41616 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1907,7 +1907,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
   GfxFont *gfxFont;
   GfxFontLoc *fontLoc;
   GfxFontType fontType;
-  SplashOutFontFileID *id;
+  SplashOutFontFileID *id = NULL;
   SplashFontFile *fontFile;
   SplashFontSrc *fontsrc = NULL;
   FoFiTrueType *ff;
@@ -1947,6 +1947,11 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
 
   // check the font file cache
 reload:
+  delete id;
+  delete fontLoc;
+  if (fontsrc && !fontsrc->isFile)
+      fontsrc->unref();
+
   id = new SplashOutFontFileID(gfxFont->getID());
   if ((fontFile = fontEngine->getFontFile(id))) {
     delete id;
commit 8639b20da3d9be62f47462ad1cdaa5c65d117dfb
Author: Thomas Freitag <[email protected]>
Date:   Sun Sep 27 15:37:51 2015 +0200

    Try to use an external font if the internal one is invalid

diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index febb902..85bdea1 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -22,6 +22,7 @@
 // Copyright (C) 2011 Axel Strübing <[email protected]>
 // Copyright (C) 2011, 2012, 2014 Adrian Johnson <[email protected]>
 // Copyright (C) 2015 Jason Crain <[email protected]>
+// Copyright (C) 2015 Thomas Freitag <[email protected]>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -211,6 +212,16 @@ public:
   GBool getEmbeddedFontID(Ref *embID)
     { *embID = embFontID; return embFontID.num >= 0; }
 
+  // Invalidate an embedded font
+  // Returns false if there is no embedded font.
+  GBool invalidateEmbeddedFont() {
+    if (embFontID.num >= 0) {
+      embFontID.num = -1;
+      return gTrue;
+    }
+    return gFalse;
+  }
+
   // Get the PostScript font name for the embedded font.  Returns
   // NULL if there is no embedded font.
   GooString *getEmbeddedFontName() { return embFontName; }
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 097260b..5275143 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1946,6 +1946,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
   }
 
   // check the font file cache
+reload:
   id = new SplashOutFontFileID(gfxFont->getID());
   if ((fontFile = fontEngine->getFontFile(id))) {
     delete id;
@@ -1989,6 +1990,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2000,6 +2002,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2011,6 +2014,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2046,6 +2050,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2057,6 +2062,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2077,6 +2083,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
@@ -2113,6 +2120,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
        error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
              gfxFont->getName() ? gfxFont->getName()->getCString()
                                 : "(unnamed)");
+       if (gfxFont->invalidateEmbeddedFont()) goto reload;
        goto err2;
       }
       break;
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to