summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fofi/FoFiType1C.cc21
-rw-r--r--fofi/FoFiType1C.h2
-rw-r--r--poppler/UnicodeMap.cc15
-rw-r--r--poppler/UnicodeMap.h4
4 files changed, 22 insertions, 20 deletions
diff --git a/fofi/FoFiType1C.cc b/fofi/FoFiType1C.cc
index 8ecc066a..cdcef18a 100644
--- a/fofi/FoFiType1C.cc
+++ b/fofi/FoFiType1C.cc
@@ -107,7 +107,7 @@ FoFiType1C::~FoFiType1C() {
charset != fofiType1CISOAdobeCharset &&
charset != fofiType1CExpertCharset &&
charset != fofiType1CExpertSubsetCharset) {
- gfree(charset);
+ gfree(const_cast<unsigned short *>(charset));
}
}
@@ -2503,25 +2503,25 @@ bool FoFiType1C::readCharset() {
int nLeft, i, j;
if (topDict.charsetOffset == 0) {
- charset = const_cast<unsigned short*>(fofiType1CISOAdobeCharset);
+ charset = fofiType1CISOAdobeCharset;
charsetLength = sizeof(fofiType1CISOAdobeCharset) / sizeof(unsigned short);
} else if (topDict.charsetOffset == 1) {
- charset = const_cast<unsigned short*>(fofiType1CExpertCharset);
+ charset = fofiType1CExpertCharset;
charsetLength = sizeof(fofiType1CExpertCharset) / sizeof(unsigned short);
} else if (topDict.charsetOffset == 2) {
- charset = const_cast<unsigned short*>(fofiType1CExpertSubsetCharset);
+ charset = fofiType1CExpertSubsetCharset;
charsetLength = sizeof(fofiType1CExpertSubsetCharset) / sizeof(unsigned short);
} else {
- charset = (unsigned short *)gmallocn(nGlyphs, sizeof(unsigned short));
+ unsigned short *customCharset = (unsigned short *)gmallocn(nGlyphs, sizeof(unsigned short));
charsetLength = nGlyphs;
for (i = 0; i < nGlyphs; ++i) {
- charset[i] = 0;
+ customCharset[i] = 0;
}
pos = topDict.charsetOffset;
charsetFormat = getU8(pos++, &parsedOk);
if (charsetFormat == 0) {
for (i = 1; i < nGlyphs; ++i) {
- charset[i] = (unsigned short)getU16BE(pos, &parsedOk);
+ customCharset[i] = (unsigned short)getU16BE(pos, &parsedOk);
pos += 2;
if (!parsedOk) {
break;
@@ -2537,7 +2537,7 @@ bool FoFiType1C::readCharset() {
break;
}
for (j = 0; j <= nLeft && i < nGlyphs; ++j) {
- charset[i++] = (unsigned short)c++;
+ customCharset[i++] = (unsigned short)c++;
}
}
} else if (charsetFormat == 2) {
@@ -2551,16 +2551,17 @@ bool FoFiType1C::readCharset() {
break;
}
for (j = 0; j <= nLeft && i < nGlyphs; ++j) {
- charset[i++] = (unsigned short)c++;
+ customCharset[i++] = (unsigned short)c++;
}
}
}
if (!parsedOk) {
- gfree(charset);
+ gfree(customCharset);
charset = nullptr;
charsetLength = 0;
return false;
}
+ charset = customCharset;
}
return true;
}
diff --git a/fofi/FoFiType1C.h b/fofi/FoFiType1C.h
index faae806d..ff69651a 100644
--- a/fofi/FoFiType1C.h
+++ b/fofi/FoFiType1C.h
@@ -246,7 +246,7 @@ private:
int nGlyphs;
int nFDs;
unsigned char *fdSelect;
- unsigned short *charset;
+ const unsigned short *charset;
unsigned short charsetLength;
int gsubrBias;
diff --git a/poppler/UnicodeMap.cc b/poppler/UnicodeMap.cc
index 6125294b..6e7e467b 100644
--- a/poppler/UnicodeMap.cc
+++ b/poppler/UnicodeMap.cc
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net>
-// Copyright (C) 2017, 2018 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr>
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
@@ -71,7 +71,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) {
map = new UnicodeMap(encodingNameA->copy());
size = 8;
- map->ranges = (UnicodeMapRange *)gmallocn(size, sizeof(UnicodeMapRange));
+ UnicodeMapRange *customRanges = (UnicodeMapRange *)gmallocn(size, sizeof(UnicodeMapRange));
eMapsSize = 0;
line = 1;
@@ -86,10 +86,10 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) {
if (nBytes <= 4) {
if (map->len == size) {
size *= 2;
- map->ranges = (UnicodeMapRange *)
- greallocn(map->ranges, size, sizeof(UnicodeMapRange));
+ customRanges = (UnicodeMapRange *)
+ greallocn(customRanges, size, sizeof(UnicodeMapRange));
}
- range = &map->ranges[map->len];
+ range = &customRanges[map->len];
sscanf(tok1, "%x", &range->start);
sscanf(tok2, "%x", &range->end);
sscanf(tok3, "%x", &range->code);
@@ -125,6 +125,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) {
fclose(f);
+ map->ranges = customRanges;
return map;
}
@@ -144,7 +145,7 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, bool unicodeOutA,
encodingName = new GooString(encodingNameA);
unicodeOut = unicodeOutA;
kind = unicodeMapResident;
- ranges = const_cast<UnicodeMapRange*>(rangesA);
+ ranges = rangesA;
len = lenA;
eMaps = nullptr;
eMapsLen = 0;
@@ -165,7 +166,7 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, bool unicodeOutA,
UnicodeMap::~UnicodeMap() {
delete encodingName;
if (kind == unicodeMapUser && ranges) {
- gfree(ranges);
+ gfree(const_cast<UnicodeMapRange *>(ranges));
}
if (eMaps) {
gfree(eMaps);
diff --git a/poppler/UnicodeMap.h b/poppler/UnicodeMap.h
index 74f6ded0..17f1d59c 100644
--- a/poppler/UnicodeMap.h
+++ b/poppler/UnicodeMap.h
@@ -16,7 +16,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
-// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2018, 2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2019 Volker Krause <vkrause@kde.org>
//
@@ -104,7 +104,7 @@ private:
UnicodeMapKind kind;
bool unicodeOut;
union {
- UnicodeMapRange *ranges; // (user, resident)
+ const UnicodeMapRange *ranges; // (user, resident)
UnicodeMapFunc func; // (func)
};
int len; // (user, resident)