[poppler] poppler/UTF.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jan 5 22:13:33 UTC 2020


 poppler/UTF.cc |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

New commits:
commit a0e6c8ffca03d324846db8b099774aafaf64627f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Jan 5 23:05:54 2020 +0100

    Fix crash in unicodeToAscii7
    
    Don't make Ascii7Map be static, otherwise it will cache the unicode map
    between globlParams and end up with a bad pointer
    
    If we find the constant searching of the unicode in globalparams is a
    speed problem we need to apply a similar solution to the one we did for
    UTF8

diff --git a/poppler/UTF.cc b/poppler/UTF.cc
index 37d21c75..cb2e6775 100644
--- a/poppler/UTF.cc
+++ b/poppler/UTF.cc
@@ -420,20 +420,11 @@ char *utf16ToUtf8(const uint16_t *utf16, int *len)
   return utf8;
 }
 
-struct Ascii7Map
-{
-  const UnicodeMap *d;
-  Ascii7Map()
-  {
-    GooString enc("ASCII7");
-    d = globalParams->getUnicodeMap(&enc);
-  }
-};
-
 void unicodeToAscii7(const Unicode *in, int len, Unicode **ucs4_out,
                      int *out_len, const int *in_idx, int **indices)
 {
-  static Ascii7Map uMap;
+  GooString enc("ASCII7");
+  const UnicodeMap *uMap = globalParams->getUnicodeMap(&enc);
   int *idx = nullptr;
 
   if (!len) {
@@ -455,7 +446,7 @@ void unicodeToAscii7(const Unicode *in, int len, Unicode **ucs4_out,
   int i, n, k;
 
   for (i = k = 0; i < len; ++i) {
-     n = uMap.d->mapUnicode(in[i], buf, sizeof(buf));
+     n = uMap->mapUnicode(in[i], buf, sizeof(buf));
      if (!n) {
        // the Unicode char could not be converted to ascii7 counterpart
        // so just fill with a non-printable ascii char


More information about the poppler mailing list