summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2020-01-05 23:05:54 +0100
committerAlbert Astals Cid <aacid@kde.org>2020-01-05 23:08:45 +0100
commita0e6c8ffca03d324846db8b099774aafaf64627f (patch)
treea3fcbc9931e693b28148120185d047438a741245
parentbc8250504b14655eb25d11336899bdcc032df18d (diff)
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
-rw-r--r--poppler/UTF.cc15
1 files changed, 3 insertions, 12 deletions
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