summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/poppler/GfxState.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/poppler/GfxState.cc939
1 files changed, 359 insertions, 580 deletions
diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc b/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc
index 6ac18748ade..3ad10381ed8 100644
--- a/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc
+++ b/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc
@@ -16,7 +16,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
-// Copyright (C) 2006-2016 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2017 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009, 2012 Koji Otani <sho@bbr.jp>
// Copyright (C) 2009, 2011-2016 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Christian Persch <chpe@gnome.org>
@@ -29,6 +29,7 @@
// Copyright (C) 2013 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2015 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2016 Marek Kasik <mkasik@redhat.com>
+// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.de>
//
// 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
@@ -178,40 +179,8 @@ static const char *gfxColorSpaceModeNames[] = {
static const std::map<unsigned int, unsigned int>::size_type CMSCACHE_LIMIT = 2048;
-#ifdef USE_LCMS1
-#include <lcms.h>
-#define cmsColorSpaceSignature icColorSpaceSignature
-#define cmsSetLogErrorHandler cmsSetErrorHandler
-#define cmsSigXYZData icSigXYZData
-#define cmsSigLuvData icSigLuvData
-#define cmsSigLabData icSigLabData
-#define cmsSigYCbCrData icSigYCbCrData
-#define cmsSigYxyData icSigYxyData
-#define cmsSigRgbData icSigRgbData
-#define cmsSigHsvData icSigHsvData
-#define cmsSigHlsData icSigHlsData
-#define cmsSigCmyData icSigCmyData
-#define cmsSig3colorData icSig3colorData
-#define cmsSigGrayData icSigGrayData
-#define cmsSigCmykData icSigCmykData
-#define cmsSig4colorData icSig4colorData
-#define cmsSig2colorData icSig2colorData
-#define cmsSig5colorData icSig5colorData
-#define cmsSig6colorData icSig6colorData
-#define cmsSig7colorData icSig7colorData
-#define cmsSig8colorData icSig8colorData
-#define cmsSig9colorData icSig9colorData
-#define cmsSig10colorData icSig10colorData
-#define cmsSig11colorData icSig11colorData
-#define cmsSig12colorData icSig12colorData
-#define cmsSig13colorData icSig13colorData
-#define cmsSig14colorData icSig14colorData
-#define cmsSig15colorData icSig15colorData
-#define LCMS_FLAGS 0
-#else
#include <lcms2.h>
#define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE | cmsFLAGS_BLACKPOINTCOMPENSATION
-#endif
#define COLOR_PROFILE_DIR "/ColorProfiles/"
#define GLOBAL_COLOR_PROFILE_DIR POPPLER_DATADIR COLOR_PROFILE_DIR
@@ -314,40 +283,34 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev
if (csObj->isName()) {
if (csObj->isName("DeviceGray") || csObj->isName("G")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultGray", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultGray");
if (objCS.isNull()) {
cs = new GfxDeviceGrayColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceGrayColorSpace();
}
} else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultRGB", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultRGB");
if (objCS.isNull()) {
cs = new GfxDeviceRGBColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceRGBColorSpace();
}
} else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultCMYK", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultCMYK");
if (objCS.isNull()) {
cs = new GfxDeviceCMYKColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceCMYKColorSpace();
}
@@ -357,43 +320,37 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev
error(errSyntaxWarning, -1, "Bad color space '{0:s}'", csObj->getName());
}
} else if (csObj->isArray() && csObj->arrayGetLength() > 0) {
- csObj->arrayGet(0, &obj1);
+ obj1 = csObj->arrayGet(0);
if (obj1.isName("DeviceGray") || obj1.isName("G")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultGray", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultGray");
if (objCS.isNull()) {
cs = new GfxDeviceGrayColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceGrayColorSpace();
}
} else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultRGB", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultRGB");
if (objCS.isNull()) {
cs = new GfxDeviceRGBColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceRGBColorSpace();
}
} else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultCMYK", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultCMYK");
if (objCS.isNull()) {
cs = new GfxDeviceCMYKColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceCMYKColorSpace();
}
@@ -416,52 +373,44 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev
} else {
error(errSyntaxWarning, -1, "Bad color space");
}
- obj1.free();
} else if (csObj->isDict()) {
- csObj->dictLookup("ColorSpace", &obj1);
+ obj1 = csObj->dictLookup("ColorSpace");
if (obj1.isName("DeviceGray")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultGray", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultGray");
if (objCS.isNull()) {
cs = new GfxDeviceGrayColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceGrayColorSpace();
}
} else if (obj1.isName("DeviceRGB")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultRGB", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultRGB");
if (objCS.isNull()) {
cs = new GfxDeviceRGBColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceRGBColorSpace();
}
} else if (obj1.isName("DeviceCMYK")) {
if (res != NULL) {
- Object objCS;
- res->lookupColorSpace("DefaultCMYK", &objCS);
+ Object objCS = res->lookupColorSpace("DefaultCMYK");
if (objCS.isNull()) {
cs = new GfxDeviceCMYKColorSpace();
} else {
cs = GfxColorSpace::parse(NULL, &objCS, out, state);
}
- objCS.free();
} else {
cs = new GfxDeviceCMYKColorSpace();
}
} else {
error(errSyntaxWarning, -1, "Bad color space dict'");
}
- obj1.free();
} else {
error(errSyntaxWarning, -1, "Bad color space - expected name or array or dict");
}
@@ -517,18 +466,10 @@ cmsHPROFILE loadColorProfile(const char *fileName)
return hp;
}
-#ifdef USE_LCMS1
-static int CMSError(int ecode, const char *msg)
-{
- error(errSyntaxWarning, -1, "{0:s}", msg);
- return 1;
-}
-#else
static void CMSError(cmsContext /*contextId*/, cmsUInt32Number /*ecode*/, const char *text)
{
error(errSyntaxWarning, -1, "{0:s}", text);
}
-#endif
int GfxColorSpace::setupColorProfiles()
{
@@ -830,52 +771,42 @@ static const double xyzrgb[3][3] = {
GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr, GfxState *state) {
GfxCalGrayColorSpace *cs;
- Object obj1, obj2, obj3;
+ Object obj1, obj2;
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!obj1.isDict()) {
error(errSyntaxWarning, -1, "Bad CalGray color space");
- obj1.free();
return NULL;
}
cs = new GfxCalGrayColorSpace();
- if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
+ obj2 = obj1.dictLookup("WhitePoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
if (likely(obj3.isNum()))
cs->whiteX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
+ obj3 = obj2.arrayGet(1);
if (likely(obj3.isNum()))
cs->whiteY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
+ obj3 = obj2.arrayGet(2);
if (likely(obj3.isNum()))
cs->whiteZ = obj3.getNum();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("BlackPoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
+ obj2 = obj1.dictLookup("BlackPoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
if (likely(obj3.isNum()))
cs->blackX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
+ obj3 = obj2.arrayGet(1);
if (likely(obj3.isNum()))
cs->blackY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
+ obj3 = obj2.arrayGet(2);
if (likely(obj3.isNum()))
cs->blackZ = obj3.getNum();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("Gamma", &obj2)->isNum()) {
+ obj2 = obj1.dictLookup("Gamma");
+ if (obj2.isNum()) {
cs->gamma = obj2.getNum();
}
- obj2.free();
- obj1.free();
cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
xyzrgb[0][1] * cs->whiteY +
@@ -1209,75 +1140,59 @@ GfxColorSpace *GfxCalRGBColorSpace::copy() {
GfxColorSpace *GfxCalRGBColorSpace::parse(Array *arr, GfxState *state) {
GfxCalRGBColorSpace *cs;
- Object obj1, obj2, obj3;
+ Object obj1, obj2;
int i;
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!obj1.isDict()) {
error(errSyntaxWarning, -1, "Bad CalRGB color space");
- obj1.free();
return NULL;
}
cs = new GfxCalRGBColorSpace();
- if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
+ obj2 = obj1.dictLookup("WhitePoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
if (likely(obj3.isNum()))
cs->whiteX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
+ obj3 = obj2.arrayGet(1);
if (likely(obj3.isNum()))
cs->whiteY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
+ obj3 = obj2.arrayGet(2);
if (likely(obj3.isNum()))
cs->whiteZ = obj3.getNum();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("BlackPoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
+ obj2 = obj1.dictLookup("BlackPoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
if (likely(obj3.isNum()))
cs->blackX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
+ obj3 = obj2.arrayGet(1);
if (likely(obj3.isNum()))
cs->blackY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
+ obj3 = obj2.arrayGet(2);
if (likely(obj3.isNum()))
cs->blackZ = obj3.getNum();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("Gamma", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
+ obj2 = obj1.dictLookup("Gamma");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
if (likely(obj3.isNum()))
cs->gammaR = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
+ obj3 = obj2.arrayGet(1);
if (likely(obj3.isNum()))
cs->gammaG = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
+ obj3 = obj2.arrayGet(2);
if (likely(obj3.isNum()))
cs->gammaB = obj3.getNum();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("Matrix", &obj2)->isArray() &&
- obj2.arrayGetLength() == 9) {
+ obj2 = obj1.dictLookup("Matrix");
+ if (obj2.isArray() && obj2.arrayGetLength() == 9) {
for (i = 0; i < 9; ++i) {
- obj2.arrayGet(i, &obj3);
+ Object obj3 = obj2.arrayGet(i);
if (likely(obj3.isNum()))
cs->mat[i] = obj3.getNum();
- obj3.free();
}
}
- obj2.free();
- obj1.free();
cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
xyzrgb[0][1] * cs->whiteY +
@@ -1596,58 +1511,53 @@ GfxColorSpace *GfxLabColorSpace::copy() {
GfxColorSpace *GfxLabColorSpace::parse(Array *arr, GfxState *state) {
GfxLabColorSpace *cs;
- Object obj1, obj2, obj3;
+ Object obj1, obj2;
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!obj1.isDict()) {
error(errSyntaxWarning, -1, "Bad Lab color space");
- obj1.free();
return NULL;
}
cs = new GfxLabColorSpace();
- if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
- cs->whiteX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
- cs->whiteY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
- cs->whiteZ = obj3.getNum();
- obj3.free();
- }
- obj2.free();
- if (obj1.dictLookup("BlackPoint", &obj2)->isArray() &&
- obj2.arrayGetLength() == 3) {
- obj2.arrayGet(0, &obj3);
- cs->blackX = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
- cs->blackY = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
- cs->blackZ = obj3.getNum();
- obj3.free();
- }
- obj2.free();
- if (obj1.dictLookup("Range", &obj2)->isArray() &&
- obj2.arrayGetLength() == 4) {
- obj2.arrayGet(0, &obj3);
- cs->aMin = obj3.getNum();
- obj3.free();
- obj2.arrayGet(1, &obj3);
- cs->aMax = obj3.getNum();
- obj3.free();
- obj2.arrayGet(2, &obj3);
- cs->bMin = obj3.getNum();
- obj3.free();
- obj2.arrayGet(3, &obj3);
- cs->bMax = obj3.getNum();
- obj3.free();
- }
- obj2.free();
- obj1.free();
+ bool ok = true;
+ obj2 = obj1.dictLookup("WhitePoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
+ cs->whiteX = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(1);
+ cs->whiteY = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(2);
+ cs->whiteZ = obj3.getNum(&ok);
+ }
+ obj2 = obj1.dictLookup("BlackPoint");
+ if (obj2.isArray() && obj2.arrayGetLength() == 3) {
+ Object obj3 = obj2.arrayGet(0);
+ cs->blackX = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(1);
+ cs->blackY = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(2);
+ cs->blackZ = obj3.getNum(&ok);
+ }
+ obj2 = obj1.dictLookup("Range");
+ if (obj2.isArray() && obj2.arrayGetLength() == 4) {
+ Object obj3 = obj2.arrayGet(0);
+ cs->aMin = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(1);
+ cs->aMax = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(2);
+ cs->bMin = obj3.getNum(&ok);
+ obj3 = obj2.arrayGet(3);
+ cs->bMax = obj3.getNum(&ok);
+ }
+
+ if (!ok) {
+ error(errSyntaxWarning, -1, "Bad Lab color space");
+#ifdef USE_CMS
+ cs->transform = nullptr;
+#endif
+ delete cs;
+ return nullptr;
+ }
cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
xyzrgb[0][1] * cs->whiteY +
@@ -1855,7 +1765,7 @@ class GfxICCBasedColorSpaceKey : public PopplerCacheKey
{
}
- bool operator==(const PopplerCacheKey &key) const
+ bool operator==(const PopplerCacheKey &key) const override
{
const GfxICCBasedColorSpaceKey *k = static_cast<const GfxICCBasedColorSpaceKey*>(&key);
return k->num == num && k->gen == gen;
@@ -1936,14 +1846,13 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState
error(errSyntaxError, -1, "Bad ICCBased color space");
return NULL;
}
- arr->getNF(1, &obj1);
+ obj1 = arr->getNF(1);
if (obj1.isRef()) {
iccProfileStreamA = obj1.getRef();
} else {
iccProfileStreamA.num = 0;
iccProfileStreamA.gen = 0;
}
- obj1.free();
#ifdef USE_CMS
// check cache
if (out && iccProfileStreamA.num > 0) {
@@ -1973,28 +1882,26 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState
}
}
#endif
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!obj1.isStream()) {
error(errSyntaxWarning, -1, "Bad ICCBased color space (stream)");
- obj1.free();
return NULL;
}
dict = obj1.streamGetDict();
- if (!dict->lookup("N", &obj2)->isInt()) {
+ obj2 = dict->lookup("N");
+ if (!obj2.isInt()) {
error(errSyntaxWarning, -1, "Bad ICCBased color space (N)");
- obj2.free();
- obj1.free();
- return NULL;
+ return nullptr;
}
nCompsA = obj2.getInt();
- obj2.free();
if (nCompsA > 4) {
error(errSyntaxError, -1,
"ICCBased color space with too many ({0:d} > 4) components",
nCompsA);
nCompsA = 4;
}
- if (dict->lookup("Alternate", &obj2)->isNull() ||
+ obj2 = dict->lookup("Alternate");
+ if (obj2.isNull() ||
!(altA = GfxColorSpace::parse(NULL, &obj2, out, state, recursion + 1))) {
switch (nCompsA) {
case 1:
@@ -2008,38 +1915,30 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState
break;
default:
error(errSyntaxWarning, -1, "Bad ICCBased color space - invalid N");
- obj2.free();
- obj1.free();
return NULL;
}
}
- obj2.free();
if (altA->getNComps() != nCompsA) {
error(errSyntaxWarning, -1, "Bad ICCBased color space - N doesn't match alt color space");
delete altA;
- obj1.free();
return NULL;
}
cs = new GfxICCBasedColorSpace(nCompsA, altA, &iccProfileStreamA);
- if (dict->lookup("Range", &obj2)->isArray() &&
- obj2.arrayGetLength() == 2 * nCompsA) {
+ obj2 = dict->lookup("Range");
+ if (obj2.isArray() && obj2.arrayGetLength() == 2 * nCompsA) {
Object obj4;
for (i = 0; i < nCompsA; ++i) {
- obj2.arrayGet(2*i, &obj3);
- obj2.arrayGet(2*i+1, &obj4);
+ obj3 = obj2.arrayGet(2*i);
+ obj4 = obj2.arrayGet(2*i+1);
if (obj3.isNum() && obj4.isNum()) {
cs->rangeMin[i] = obj3.getNum();
cs->rangeMax[i] = obj4.getNum();
}
- obj3.free();
- obj4.free();
}
}
- obj2.free();
- obj1.free();
#ifdef USE_CMS
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
Guchar *profBuf;
Stream *iccStream = obj1.getStream();
int length = 0;
@@ -2099,7 +1998,6 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState
}
cmsCloseProfile(hp);
}
- obj1.free();
// put this colorSpace into cache
if (out && iccProfileStreamA.num > 0) {
GfxICCBasedColorSpaceKey *k = new GfxICCBasedColorSpaceKey(iccProfileStreamA.num, iccProfileStreamA.gen);
@@ -2581,27 +2479,26 @@ GfxColorSpace *GfxIndexedColorSpace::copy() {
}
GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
- GfxIndexedColorSpace *cs;
GfxColorSpace *baseA;
int indexHighA;
Object obj1;
char *s;
- int n, i, j;
+ int i, j;
if (arr->getLength() != 4) {
error(errSyntaxWarning, -1, "Bad Indexed color space");
- goto err1;
+ return nullptr;
}
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!(baseA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
error(errSyntaxWarning, -1, "Bad Indexed color space (base color space)");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (!arr->get(2, &obj1)->isInt()) {
+ obj1 = arr->get(2);
+ if (!obj1.isInt()) {
error(errSyntaxWarning, -1, "Bad Indexed color space (hival)");
delete baseA;
- goto err2;
+ return nullptr;
}
indexHighA = obj1.getInt();
if (indexHighA < 0 || indexHighA > 255) {
@@ -2614,10 +2511,9 @@ GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, Output
else indexHighA = 255;
error(errSyntaxWarning, -1, "Bad Indexed color space (invalid indexHigh value, was {0:d} using {1:d} to try to recover)", previousValue, indexHighA);
}
- obj1.free();
- cs = new GfxIndexedColorSpace(baseA, indexHighA);
- arr->get(3, &obj1);
- n = baseA->getNComps();
+ GfxIndexedColorSpace *cs = new GfxIndexedColorSpace(baseA, indexHighA);
+ obj1 = arr->get(3);
+ const int n = baseA->getNComps();
if (obj1.isStream()) {
obj1.streamReset();
for (i = 0; i <= indexHighA; ++i) {
@@ -2643,15 +2539,11 @@ GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, Output
error(errSyntaxWarning, -1, "Bad Indexed color space (lookup table)");
goto err3;
}
- obj1.free();
return cs;
err3:
delete cs;
- err2:
- obj1.free();
- err1:
- return NULL;
+ return nullptr;
}
GfxColor *GfxIndexedColorSpace::mapColorToBase(GfxColor *color,
@@ -2663,7 +2555,7 @@ GfxColor *GfxIndexedColorSpace::mapColorToBase(GfxColor *color,
n = base->getNComps();
base->getDefaultRanges(low, range, indexHigh);
const int idx = (int)(colToDbl(color->c[0]) + 0.5) * n;
- if (likely((idx + n < (indexHigh + 1) * base->getNComps()) && idx >= 0)) {
+ if (likely((idx + n - 1 < (indexHigh + 1) * base->getNComps()) && idx >= 0)) {
p = &lookup[idx];
for (i = 0; i < n; ++i) {
baseColor->c[i] = dblToCol(low[i] + (p[i] / 255.0) * range[i]);
@@ -2856,19 +2748,18 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out
error(errSyntaxWarning, -1, "Bad Separation color space");
goto err1;
}
- if (!arr->get(1, &obj1)->isName()) {
+ obj1 = arr->get(1);
+ if (!obj1.isName()) {
error(errSyntaxWarning, -1, "Bad Separation color space (name)");
- goto err2;
+ goto err1;
}
nameA = new GooString(obj1.getName());
- obj1.free();
- arr->get(2, &obj1);
+ obj1 = arr->get(2);
if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
error(errSyntaxWarning, -1, "Bad Separation color space (alternate color space)");
goto err3;
}
- obj1.free();
- arr->get(3, &obj1);
+ obj1 = arr->get(3);
if (!(funcA = Function::parse(&obj1))) {
goto err4;
}
@@ -2876,7 +2767,6 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out
error(errSyntaxWarning, -1, "Bad SeparationColorSpace function");
goto err5;
}
- obj1.free();
cs = new GfxSeparationColorSpace(nameA, altA, funcA);
return cs;
@@ -2886,10 +2776,8 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out
delete altA;
err3:
delete nameA;
- err2:
- obj1.free();
err1:
- return NULL;
+ return nullptr;
}
void GfxSeparationColorSpace::getGray(GfxColor *color, GfxGray *gray) {
@@ -3131,12 +3019,11 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
//~ handle the 'None' colorant
GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
- GfxDeviceNColorSpace *cs;
int nCompsA;
GooString *namesA[gfxColorMaxComps];
GfxColorSpace *altA;
Function *funcA;
- Object obj1, obj2;
+ Object obj1;
int i;
GooList *separationList = new GooList();
@@ -3144,9 +3031,10 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output
error(errSyntaxWarning, -1, "Bad DeviceN color space");
goto err1;
}
- if (!arr->get(1, &obj1)->isArray()) {
+ obj1 = arr->get(1);
+ if (!obj1.isArray()) {
error(errSyntaxWarning, -1, "Bad DeviceN color space (names)");
- goto err2;
+ goto err1;
}
nCompsA = obj1.arrayGetLength();
if (nCompsA > gfxColorMaxComps) {
@@ -3155,63 +3043,53 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output
nCompsA = gfxColorMaxComps;
}
for (i = 0; i < nCompsA; ++i) {
- if (!obj1.arrayGet(i, &obj2)->isName()) {
+ Object obj2 = obj1.arrayGet(i);
+ if (!obj2.isName()) {
error(errSyntaxWarning, -1, "Bad DeviceN color space (names)");
- obj2.free();
- goto err2;
+ goto err1;
}
namesA[i] = new GooString(obj2.getName());
- obj2.free();
}
- obj1.free();
- arr->get(2, &obj1);
+ obj1 = arr->get(2);
if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
error(errSyntaxWarning, -1, "Bad DeviceN color space (alternate color space)");
goto err3;
}
- obj1.free();
- arr->get(3, &obj1);
+ obj1 = arr->get(3);
if (!(funcA = Function::parse(&obj1))) {
goto err4;
}
- obj1.free();
if (arr->getLength() == 5) {
- if (!arr->get(4, &obj1)->isDict()) {
+ obj1 = arr->get(4);
+ if (!obj1.isDict()) {
error(errSyntaxWarning, -1, "Bad DeviceN color space (attributes)");
- goto err4;
+ goto err5;
}
Dict *attribs = obj1.getDict();
- attribs->lookup("Colorants", &obj2);
+ Object obj2 = attribs->lookup("Colorants");
if (obj2.isDict()) {
Dict *colorants = obj2.getDict();
for (i = 0; i < colorants->getLength(); i++) {
- Object obj3;
- colorants->getVal(i, &obj3);
+ Object obj3 = colorants->getVal(i);
if (obj3.isArray()) {
separationList->append(GfxSeparationColorSpace::parse(res, obj3.getArray(), out, state, recursion));
} else {
- obj3.free();
- obj2.free();
error(errSyntaxWarning, -1, "Bad DeviceN color space (colorant value entry is not an Array)");
- goto err4;
+ goto err5;
}
- obj3.free();
}
}
- obj2.free();
- obj1.free();
}
- cs = new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList);
- return cs;
+ return new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList);
+ err5:
+ delete funcA;
err4:
delete altA;
err3:
for (i = 0; i < nCompsA; ++i) {
delete namesA[i];
}
- err2:
- obj1.free();
err1:
delete separationList;
return NULL;
@@ -3407,13 +3285,11 @@ GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, Array *arr, Output
}
underA = NULL;
if (arr->getLength() == 2) {
- arr->get(1, &obj1);
+ obj1 = arr->get(1);
if (!(underA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) {
error(errSyntaxWarning, -1, "Bad Pattern color space (underlying color space)");
- obj1.free();
return NULL;
}
- obj1.free();
}
cs = new GfxPatternColorSpace(underA);
return cs;
@@ -3446,31 +3322,33 @@ void GfxPatternColorSpace::getDefaultColor(GfxColor *color) {
// Pattern
//------------------------------------------------------------------------
-GfxPattern::GfxPattern(int typeA) {
- type = typeA;
+GfxPattern::GfxPattern(int typeA, int patternRefNumA)
+ : type(typeA)
+ , patternRefNum(patternRefNumA)
+{
+
}
GfxPattern::~GfxPattern() {
}
-GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) {
+GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum) {
GfxPattern *pattern;
Object obj1;
if (obj->isDict()) {
- obj->dictLookup("PatternType", &obj1);
+ obj1 = obj->dictLookup("PatternType");
} else if (obj->isStream()) {
- obj->streamGetDict()->lookup("PatternType", &obj1);
+ obj1 = obj->streamGetDict()->lookup("PatternType");
} else {
- return NULL;
+ return nullptr;
}
pattern = NULL;
if (obj1.isInt() && obj1.getInt() == 1) {
- pattern = GfxTilingPattern::parse(obj);
+ pattern = GfxTilingPattern::parse(obj, patternRefNum);
} else if (obj1.isInt() && obj1.getInt() == 2) {
- pattern = GfxShadingPattern::parse(res, obj, out, state);
+ pattern = GfxShadingPattern::parse(res, obj, out, state, patternRefNum);
}
- obj1.free();
return pattern;
}
@@ -3478,14 +3356,13 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, Gf
// GfxTilingPattern
//------------------------------------------------------------------------
-GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) {
- GfxTilingPattern *pat;
+GfxTilingPattern *GfxTilingPattern::parse(Object *patObj, int patternRefNum) {
Dict *dict;
int paintTypeA, tilingTypeA;
double bboxA[4], matrixA[6];
double xStepA, yStepA;
Object resDictA;
- Object obj1, obj2;
+ Object obj1;
int i;
if (!patObj->isStream()) {
@@ -3493,78 +3370,73 @@ GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) {
}
dict = patObj->streamGetDict();
- if (dict->lookup("PaintType", &obj1)->isInt()) {
+ obj1 = dict->lookup("PaintType");
+ if (obj1.isInt()) {
paintTypeA = obj1.getInt();
} else {
paintTypeA = 1;
error(errSyntaxWarning, -1, "Invalid or missing PaintType in pattern");
}
- obj1.free();
- if (dict->lookup("TilingType", &obj1)->isInt()) {
+ obj1 = dict->lookup("TilingType");
+ if (obj1.isInt()) {
tilingTypeA = obj1.getInt();
} else {
tilingTypeA = 1;
error(errSyntaxWarning, -1, "Invalid or missing TilingType in pattern");
}
- obj1.free();
bboxA[0] = bboxA[1] = 0;
bboxA[2] = bboxA[3] = 1;
- if (dict->lookup("BBox", &obj1)->isArray() &&
- obj1.arrayGetLength() == 4) {
+ obj1 = dict->lookup("BBox");
+ if (obj1.isArray() && obj1.arrayGetLength() == 4) {
for (i = 0; i < 4; ++i) {
- if (obj1.arrayGet(i, &obj2)->isNum()) {
+ Object obj2 = obj1.arrayGet(i);
+ if (obj2.isNum()) {
bboxA[i] = obj2.getNum();
}
- obj2.free();
}
} else {
error(errSyntaxWarning, -1, "Invalid or missing BBox in pattern");
}
- obj1.free();
- if (dict->lookup("XStep", &obj1)->isNum()) {
+ obj1 = dict->lookup("XStep");
+ if (obj1.isNum()) {
xStepA = obj1.getNum();
} else {
xStepA = 1;
error(errSyntaxWarning, -1, "Invalid or missing XStep in pattern");
}
- obj1.free();
- if (dict->lookup("YStep", &obj1)->isNum()) {
+ obj1 = dict->lookup("YStep");
+ if (obj1.isNum()) {
yStepA = obj1.getNum();
} else {
yStepA = 1;
error(errSyntaxWarning, -1, "Invalid or missing YStep in pattern");
}
- obj1.free();
- if (!dict->lookup("Resources", &resDictA)->isDict()) {
- resDictA.free();
- resDictA.initNull();
+ resDictA = dict->lookup("Resources");
+ if (!resDictA.isDict()) {
error(errSyntaxWarning, -1, "Invalid or missing Resources in pattern");
}
matrixA[0] = 1; matrixA[1] = 0;
matrixA[2] = 0; matrixA[3] = 1;
matrixA[4] = 0; matrixA[5] = 0;
- if (dict->lookup("Matrix", &obj1)->isArray() &&
- obj1.arrayGetLength() == 6) {
+ obj1 = dict->lookup("Matrix");
+ if (obj1.isArray() && obj1.arrayGetLength() == 6) {
for (i = 0; i < 6; ++i) {
- if (obj1.arrayGet(i, &obj2)->isNum()) {
+ Object obj2 = obj1.arrayGet(i);
+ if (obj2.isNum()) {
matrixA[i] = obj2.getNum();
}
- obj2.free();
}
}
- obj1.free();
- pat = new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA,
- &resDictA, matrixA, patObj);
- resDictA.free();
- return pat;
+ return new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA,
+ &resDictA, matrixA, patObj, patternRefNum);
}
GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA,
double *bboxA, double xStepA, double yStepA,
Object *resDictA, double *matrixA,
- Object *contentStreamA):
- GfxPattern(1)
+ Object *contentStreamA, int patternRefNumA) :
+ GfxPattern(1, patternRefNumA)
{
int i;
@@ -3575,32 +3447,30 @@ GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA,
}
xStep = xStepA;
yStep = yStepA;
- resDictA->copy(&resDict);
+ resDict = resDictA->copy();
for (i = 0; i < 6; ++i) {
matrix[i] = matrixA[i];
}
- contentStreamA->copy(&contentStream);
+ contentStream = contentStreamA->copy();
}
GfxTilingPattern::~GfxTilingPattern() {
- resDict.free();
- contentStream.free();
}
GfxPattern *GfxTilingPattern::copy() {
return new GfxTilingPattern(paintType, tilingType, bbox, xStep, yStep,
- &resDict, matrix, &contentStream);
+ &resDict, matrix, &contentStream, getPatternRefNum());
}
//------------------------------------------------------------------------
// GfxShadingPattern
//------------------------------------------------------------------------
-GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state) {
+GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum) {
Dict *dict;
GfxShading *shadingA;
double matrixA[6];
- Object obj1, obj2;
+ Object obj1;
int i;
if (!patObj->isDict()) {
@@ -3608,9 +3478,8 @@ GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, O
}
dict = patObj->getDict();
- dict->lookup("Shading", &obj1);
+ obj1 = dict->lookup("Shading");
shadingA = GfxShading::parse(res, &obj1, out, state);
- obj1.free();
if (!shadingA) {
return NULL;
}
@@ -3618,22 +3487,21 @@ GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, O
matrixA[0] = 1; matrixA[1] = 0;
matrixA[2] = 0; matrixA[3] = 1;
matrixA[4] = 0; matrixA[5] = 0;
- if (dict->lookup("Matrix", &obj1)->isArray() &&
- obj1.arrayGetLength() == 6) {
+ obj1 = dict->lookup("Matrix");
+ if (obj1.isArray() && obj1.arrayGetLength() == 6) {
for (i = 0; i < 6; ++i) {
- if (obj1.arrayGet(i, &obj2)->isNum()) {
+ Object obj2 = obj1.arrayGet(i);
+ if (obj2.isNum()) {
matrixA[i] = obj2.getNum();
}
- obj2.free();
}
}
- obj1.free();
- return new GfxShadingPattern(shadingA, matrixA);
+ return new GfxShadingPattern(shadingA, matrixA, patternRefNum);
}
-GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA):
- GfxPattern(2)
+GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA):
+ GfxPattern(2, patternRefNumA)
{
int i;
@@ -3648,7 +3516,7 @@ GfxShadingPattern::~GfxShadingPattern() {
}
GfxPattern *GfxShadingPattern::copy() {
- return new GfxShadingPattern(shading->copy(), matrix);
+ return new GfxShadingPattern(shading->copy(), matrix, getPatternRefNum());
}
//------------------------------------------------------------------------
@@ -3696,13 +3564,12 @@ GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, Gf
return NULL;
}
- if (!dict->lookup("ShadingType", &obj1)->isInt()) {
+ obj1 = dict->lookup("ShadingType");
+ if (!obj1.isInt()) {
error(errSyntaxWarning, -1, "Invalid ShadingType in shading dictionary");
- obj1.free();
return NULL;
}
typeA = obj1.getInt();
- obj1.free();
switch (typeA) {
case 1:
@@ -3758,43 +3625,41 @@ GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, Gf
}
GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) {
- Object obj1, obj2;
+ Object obj1;
int i;
- dict->lookup("ColorSpace", &obj1);
+ obj1 = dict->lookup("ColorSpace");
if (!(colorSpace = GfxColorSpace::parse(res, &obj1, out, state))) {
error(errSyntaxWarning, -1, "Bad color space in shading dictionary");
- obj1.free();
return gFalse;
}
- obj1.free();
for (i = 0; i < gfxColorMaxComps; ++i) {
background.c[i] = 0;
}
hasBackground = gFalse;
- if (dict->lookup("Background", &obj1)->isArray()) {
+ obj1 = dict->lookup("Background");
+ if (obj1.isArray()) {
if (obj1.arrayGetLength() == colorSpace->getNComps()) {
hasBackground = gTrue;
for (i = 0; i < colorSpace->getNComps(); ++i) {
- background.c[i] = dblToCol(obj1.arrayGet(i, &obj2)->getNum());
- obj2.free();
+ Object obj2 = obj1.arrayGet(i);
+ background.c[i] = dblToCol(obj2.getNum());
}
} else {
error(errSyntaxWarning, -1, "Bad Background in shading dictionary");
}
}
- obj1.free();
xMin = yMin = xMax = yMax = 0;
hasBBox = gFalse;
- if (dict->lookup("BBox", &obj1)->isArray()) {
+ obj1 = dict->lookup("BBox");
+ if (obj1.isArray()) {
if (obj1.arrayGetLength() == 4) {
- Object obj3, obj4, obj5;
- obj1.arrayGet(0, &obj2);
- obj1.arrayGet(1, &obj3);
- obj1.arrayGet(2, &obj4);
- obj1.arrayGet(3, &obj5);
+ Object obj2 = obj1.arrayGet(0);
+ Object obj3 = obj1.arrayGet(1);
+ Object obj4 = obj1.arrayGet(2);
+ Object obj5 = obj1.arrayGet(3);
if (obj2.isNum() && obj3.isNum() && obj4.isNum() && obj5.isNum())
{
hasBBox = gTrue;
@@ -3805,15 +3670,10 @@ GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *
} else {
error(errSyntaxWarning, -1, "Bad BBox in shading dictionary (Values not numbers)");
}
- obj2.free();
- obj3.free();
- obj4.free();
- obj5.free();
} else {
error(errSyntaxWarning, -1, "Bad BBox in shading dictionary");
}
}
- obj1.free();
return gTrue;
}
@@ -3875,65 +3735,53 @@ GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, Out
double matrixA[6];
Function *funcsA[gfxColorMaxComps];
int nFuncsA;
- Object obj1, obj2;
+ Object obj1;
int i;
x0A = y0A = 0;
x1A = y1A = 1;
- if (dict->lookup("Domain", &obj1)->isArray() &&
- obj1.arrayGetLength() == 4) {
- x0A = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- x1A = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
- y0A = obj1.arrayGet(2, &obj2)->getNum();
- obj2.free();
- y1A = obj1.arrayGet(3, &obj2)->getNum();
- obj2.free();
- }
- obj1.free();
+ obj1 = dict->lookup("Domain");
+ if (obj1.isArray() && obj1.arrayGetLength() == 4) {
+ Object obj2;
+ x0A = (obj2 = obj1.arrayGet(0), obj2.getNum());
+ x1A = (obj2 = obj1.arrayGet(1), obj2.getNum());
+ y0A = (obj2 = obj1.arrayGet(2), obj2.getNum());
+ y1A = (obj2 = obj1.arrayGet(3), obj2.getNum());
+ }
matrixA[0] = 1; matrixA[1] = 0;
matrixA[2] = 0; matrixA[3] = 1;
matrixA[4] = 0; matrixA[5] = 0;
- if (dict->lookup("Matrix", &obj1)->isArray() &&
- obj1.arrayGetLength() == 6) {
- matrixA[0] = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- matrixA[1] = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
- matrixA[2] = obj1.arrayGet(2, &obj2)->getNum();
- obj2.free();
- matrixA[3] = obj1.arrayGet(3, &obj2)->getNum();
- obj2.free();
- matrixA[4] = obj1.arrayGet(4, &obj2)->getNum();
- obj2.free();
- matrixA[5] = obj1.arrayGet(5, &obj2)->getNum();
- obj2.free();
- }
- obj1.free();
-
- dict->lookup("Function", &obj1);
+ obj1 = dict->lookup("Matrix");
+ if (obj1.isArray() && obj1.arrayGetLength() == 6) {
+ Object obj2;
+ matrixA[0] = (obj2 = obj1.arrayGet(0), obj2.getNum());
+ matrixA[1] = (obj2 = obj1.arrayGet(1), obj2.getNum());
+ matrixA[2] = (obj2 = obj1.arrayGet(2), obj2.getNum());
+ matrixA[3] = (obj2 = obj1.arrayGet(3), obj2.getNum());
+ matrixA[4] = (obj2 = obj1.arrayGet(4), obj2.getNum());
+ matrixA[5] = (obj2 = obj1.arrayGet(5), obj2.getNum());
+ }
+
+ obj1 = dict->lookup("Function");
if (obj1.isArray()) {
nFuncsA = obj1.arrayGetLength();
if (nFuncsA > gfxColorMaxComps || nFuncsA <= 0) {
error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary");
- goto err1;
+ return nullptr;
}
for (i = 0; i < nFuncsA; ++i) {
- obj1.arrayGet(i, &obj2);
+ Object obj2 = obj1.arrayGet(i);
if (!(funcsA[i] = Function::parse(&obj2))) {
- goto err2;
+ return nullptr;
}
- obj2.free();
}
} else {
nFuncsA = 1;
if (!(funcsA[0] = Function::parse(&obj1))) {
- goto err1;
+ return nullptr;
}
}
- obj1.free();
shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA,
funcsA, nFuncsA);
@@ -3942,12 +3790,6 @@ GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, Out
return NULL;
}
return shading;
-
- err2:
- obj2.free();
- err1:
- obj1.free();
- return NULL;
}
GfxShading *GfxFunctionShading::copy() {
@@ -4034,11 +3876,17 @@ GfxUnivariateShading::~GfxUnivariateShading() {
void GfxUnivariateShading::getColor(double t, GfxColor *color) {
double out[gfxColorMaxComps];
- int i, nComps;
+ int i;
// NB: there can be one function with n outputs or n functions with
// one output each (where n = number of color components)
- nComps = nFuncs * funcs[0]->getOutputSize();
+ const int nComps = nFuncs * funcs[0]->getOutputSize();
+
+ if (unlikely(nFuncs < 1 || nComps > gfxColorMaxComps)) {
+ for (int i = 0; i < gfxColorMaxComps; i++)
+ color->c[i] = 0;
+ return;
+ }
if (cacheSize > 0) {
double x, ix, *l, *u, *upper;
@@ -4089,6 +3937,9 @@ void GfxUnivariateShading::setupCache(const Matrix *ctm,
cacheBounds = NULL;
cacheSize = 0;
+ if (unlikely(nFuncs < 1))
+ return;
+
// NB: there can be one function with n outputs or n functions with
// one output each (where n = number of color components)
nComps = nFuncs * funcs[0]->getOutputSize();
@@ -4195,104 +4046,83 @@ GfxAxialShading *GfxAxialShading::parse(GfxResources *res, Dict *dict, OutputDev
Function *funcsA[gfxColorMaxComps];
int nFuncsA;
GBool extend0A, extend1A;
- Object obj1, obj2;
+ Object obj1;
int i;
x0A = y0A = x1A = y1A = 0;
- if (dict->lookup("Coords", &obj1)->isArray() &&
- obj1.arrayGetLength() == 4) {
- Object obj3, obj4, obj5;
- obj1.arrayGet(0, &obj2);
- obj1.arrayGet(1, &obj3);
- obj1.arrayGet(2, &obj4);
- obj1.arrayGet(3, &obj5);
+ obj1 = dict->lookup("Coords");
+ if (obj1.isArray() && obj1.arrayGetLength() == 4) {
+ Object obj2 = obj1.arrayGet(0);
+ Object obj3 = obj1.arrayGet(1);
+ Object obj4 = obj1.arrayGet(2);
+ Object obj5 = obj1.arrayGet(3);
if (obj2.isNum() && obj3.isNum() && obj4.isNum() && obj5.isNum()) {
x0A = obj2.getNum();
y0A = obj3.getNum();
x1A = obj4.getNum();
y1A = obj5.getNum();
}
- obj2.free();
- obj3.free();
- obj4.free();
- obj5.free();
} else {
error(errSyntaxWarning, -1, "Missing or invalid Coords in shading dictionary");
- goto err1;
+ return nullptr;
}
- obj1.free();
t0A = 0;
t1A = 1;
- if (dict->lookup("Domain", &obj1)->isArray() &&
- obj1.arrayGetLength() == 2) {
- Object obj3;
- obj1.arrayGet(0, &obj2);
- obj1.arrayGet(1, &obj3);
+ obj1 = dict->lookup("Domain");
+ if (obj1.isArray() && obj1.arrayGetLength() == 2) {
+ Object obj2 = obj1.arrayGet(0);
+ Object obj3 = obj1.arrayGet(1);
if (obj2.isNum() && obj3.isNum()) {
t0A = obj2.getNum();
t1A = obj3.getNum();
}
- obj2.free();
- obj3.free();
}
- obj1.free();
- dict->lookup("Function", &obj1);
+ obj1 = dict->lookup("Function");
if (obj1.isArray()) {
nFuncsA = obj1.arrayGetLength();
if (nFuncsA > gfxColorMaxComps || nFuncsA == 0) {
error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary");
- goto err1;
+ return nullptr;
}
for (i = 0; i < nFuncsA; ++i) {
- obj1.arrayGet(i, &obj2);
+ Object obj2 = obj1.arrayGet(i);
if (!(funcsA[i] = Function::parse(&obj2))) {
- obj1.free();
- obj2.free();
- goto err1;
+ return nullptr;
}
- obj2.free();
}
} else {
nFuncsA = 1;
if (!(funcsA[0] = Function::parse(&obj1))) {
- obj1.free();
- goto err1;
+ return nullptr;
}
}
- obj1.free();
extend0A = extend1A = gFalse;
- if (dict->lookup("Extend", &obj1)->isArray() &&
- obj1.arrayGetLength() == 2) {
- obj1.arrayGet(0, &obj2);
+ obj1 = dict->lookup("Extend");
+ if (obj1.isArray() && obj1.arrayGetLength() == 2) {
+ Object obj2 = obj1.arrayGet(0);
if (obj2.isBool()) {
extend0A = obj2.getBool();
} else {
error(errSyntaxWarning, -1, "Invalid axial shading extend (0)");
}
- obj2.free();
- obj1.arrayGet(1, &obj2);
+ obj2 = obj1.arrayGet(1);
if (obj2.isBool()) {
extend1A = obj2.getBool();
} else {
error(errSyntaxWarning, -1, "Invalid axial shading extend (1)");
}
- obj2.free();
}
- obj1.free();
shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A,
funcsA, nFuncsA, extend0A, extend1A);
if (!shading->init(res, dict, out, state)) {
delete shading;
- return NULL;
+ shading = nullptr;
}
return shading;
-
- err1:
- return NULL;
}
GfxShading *GfxAxialShading::copy() {
@@ -4403,75 +4233,60 @@ GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputD
Function *funcsA[gfxColorMaxComps];
int nFuncsA;
GBool extend0A, extend1A;
- Object obj1, obj2;
+ Object obj1;
int i;
x0A = y0A = r0A = x1A = y1A = r1A = 0;
- if (dict->lookup("Coords", &obj1)->isArray() &&
- obj1.arrayGetLength() == 6) {
- x0A = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- y0A = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
- r0A = obj1.arrayGet(2, &obj2)->getNum();
- obj2.free();
- x1A = obj1.arrayGet(3, &obj2)->getNum();
- obj2.free();
- y1A = obj1.arrayGet(4, &obj2)->getNum();
- obj2.free();
- r1A = obj1.arrayGet(5, &obj2)->getNum();
- obj2.free();
+ obj1 = dict->lookup("Coords");
+ if (obj1.isArray() && obj1.arrayGetLength() == 6) {
+ Object obj2;
+ x0A = (obj2 = obj1.arrayGet(0), obj2.getNum());
+ y0A = (obj2 = obj1.arrayGet(1), obj2.getNum());
+ r0A = (obj2 = obj1.arrayGet(2), obj2.getNum());
+ x1A = (obj2 = obj1.arrayGet(3), obj2.getNum());
+ y1A = (obj2 = obj1.arrayGet(4), obj2.getNum());
+ r1A = (obj2 = obj1.arrayGet(5), obj2.getNum());
} else {
error(errSyntaxWarning, -1, "Missing or invalid Coords in shading dictionary");
- goto err1;
+ return nullptr;
}
- obj1.free();
t0A = 0;
t1A = 1;
- if (dict->lookup("Domain", &obj1)->isArray() &&
- obj1.arrayGetLength() == 2) {
- t0A = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- t1A = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
+ obj1 = dict->lookup("Domain");
+ if (obj1.isArray() && obj1.arrayGetLength() == 2) {
+ Object obj2;
+ t0A = (obj2 = obj1.arrayGet(0), obj2.getNum());
+ t1A = (obj2 = obj1.arrayGet(1), obj2.getNum());
}
- obj1.free();
- dict->lookup("Function", &obj1);
+ obj1 = dict->lookup("Function");
if (obj1.isArray()) {
nFuncsA = obj1.arrayGetLength();
if (nFuncsA > gfxColorMaxComps) {
error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary");
- goto err1;
+ return nullptr;
}
for (i = 0; i < nFuncsA; ++i) {
- obj1.arrayGet(i, &obj2);
+ Object obj2 = obj1.arrayGet(i);
if (!(funcsA[i] = Function::parse(&obj2))) {
- obj1.free();
- obj2.free();
- goto err1;
+ return nullptr;
}
- obj2.free();
}
} else {
nFuncsA = 1;
if (!(funcsA[0] = Function::parse(&obj1))) {
- obj1.free();
- goto err1;
+ return nullptr;
}
}
- obj1.free();
extend0A = extend1A = gFalse;
- if (dict->lookup("Extend", &obj1)->isArray() &&
- obj1.arrayGetLength() == 2) {
- extend0A = obj1.arrayGet(0, &obj2)->getBool();
- obj2.free();
- extend1A = obj1.arrayGet(1, &obj2)->getBool();
- obj2.free();
+ obj1 = dict->lookup("Extend");
+ if (obj1.isArray() && obj1.arrayGetLength() == 2) {
+ Object obj2;
+ extend0A = (obj2 = obj1.arrayGet(0), obj2.getBool());
+ extend1A = (obj2 = obj1.arrayGet(1), obj2.getBool());
}
- obj1.free();
shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A,
funcsA, nFuncsA, extend0A, extend1A);
@@ -4480,9 +4295,6 @@ GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputD
return NULL;
}
return shading;
-
- err1:
- return NULL;
}
GfxShading *GfxRadialShading::copy() {
@@ -4934,94 +4746,84 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, i
Guint x, y, flag;
Guint c[gfxColorMaxComps];
GfxShadingBitBuf *bitBuf;
- Object obj1, obj2;
+ Object obj1;
int i, j, k, state;
- if (dict->lookup("BitsPerCoordinate", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerCoordinate");
+ if (obj1.isInt()) {
coordBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerCoordinate in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (dict->lookup("BitsPerComponent", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerComponent");
+ if (obj1.isInt()) {
compBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerComponent in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
flagBits = vertsPerRow = 0; // make gcc happy
if (typeA == 4) {
- if (dict->lookup("BitsPerFlag", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerFlag");
+ if (obj1.isInt()) {
flagBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerFlag in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
} else {
- if (dict->lookup("VerticesPerRow", &obj1)->isInt()) {
+ obj1 = dict->lookup("VerticesPerRow");
+ if (obj1.isInt()) {
vertsPerRow = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid VerticesPerRow in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
}
- if (dict->lookup("Decode", &obj1)->isArray() &&
- obj1.arrayGetLength() >= 6) {
- xMin = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- xMax = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
+ obj1 = dict->lookup("Decode");
+ if (obj1.isArray() && obj1.arrayGetLength() >= 6) {
+ Object obj2;
+ xMin = (obj2 = obj1.arrayGet(0), obj2.getNum());
+ xMax = (obj2 = obj1.arrayGet(1), obj2.getNum());
xMul = (xMax - xMin) / (pow(2.0, coordBits) - 1);
- yMin = obj1.arrayGet(2, &obj2)->getNum();
- obj2.free();
- yMax = obj1.arrayGet(3, &obj2)->getNum();
- obj2.free();
+ yMin = (obj2 = obj1.arrayGet(2), obj2.getNum());
+ yMax = (obj2 = obj1.arrayGet(3), obj2.getNum());
yMul = (yMax - yMin) / (pow(2.0, coordBits) - 1);
for (i = 0; 5 + 2*i < obj1.arrayGetLength() && i < gfxColorMaxComps; ++i) {
- cMin[i] = obj1.arrayGet(4 + 2*i, &obj2)->getNum();
- obj2.free();
- cMax[i] = obj1.arrayGet(5 + 2*i, &obj2)->getNum();
- obj2.free();
+ cMin[i] = (obj2 = obj1.arrayGet(4 + 2*i), obj2.getNum());
+ cMax[i] = (obj2 = obj1.arrayGet(5 + 2*i), obj2.getNum());
cMul[i] = (cMax[i] - cMin[i]) / (double)((1 << compBits) - 1);
}
nComps = i;
} else {
error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (!dict->lookup("Function", &obj1)->isNull()) {
+ obj1 = dict->lookup("Function");
+ if (!obj1.isNull()) {
if (obj1.isArray()) {
nFuncsA = obj1.arrayGetLength();
if (nFuncsA > gfxColorMaxComps) {
error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary");
- goto err1;
+ return nullptr;
}
for (i = 0; i < nFuncsA; ++i) {
- obj1.arrayGet(i, &obj2);
+ Object obj2 = obj1.arrayGet(i);
if (!(funcsA[i] = Function::parse(&obj2))) {
- obj1.free();
- obj2.free();
- goto err1;
+ return nullptr;
}
- obj2.free();
}
} else {
nFuncsA = 1;
if (!(funcsA[0] = Function::parse(&obj1))) {
- obj1.free();
- goto err1;
+ return nullptr;
}
}
} else {
nFuncsA = 0;
}
- obj1.free();
nVerticesA = nTrianglesA = 0;
verticesA = NULL;
@@ -5120,11 +4922,6 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, i
return NULL;
}
return shading;
-
- err2:
- obj1.free();
- err1:
- return NULL;
}
GfxShading *GfxGouraudTriangleShading::copy() {
@@ -5285,83 +5082,79 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
double c[4][gfxColorMaxComps];
Guint ci;
GfxShadingBitBuf *bitBuf;
- Object obj1, obj2;
+ Object obj1;
int i, j;
- if (dict->lookup("BitsPerCoordinate", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerCoordinate");
+ if (obj1.isInt()) {
coordBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerCoordinate in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (dict->lookup("BitsPerComponent", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerComponent");
+ if (obj1.isInt()) {
compBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerComponent in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (dict->lookup("BitsPerFlag", &obj1)->isInt()) {
+ obj1 = dict->lookup("BitsPerFlag");
+ if (obj1.isInt()) {
flagBits = obj1.getInt();
} else {
error(errSyntaxWarning, -1, "Missing or invalid BitsPerFlag in shading dictionary");
- goto err2;
- }
- obj1.free();
- if (dict->lookup("Decode", &obj1)->isArray() &&
- obj1.arrayGetLength() >= 6) {
- xMin = obj1.arrayGet(0, &obj2)->getNum();
- obj2.free();
- xMax = obj1.arrayGet(1, &obj2)->getNum();
- obj2.free();
+ return nullptr;
+ }
+ obj1 = dict->lookup("Decode");
+ if (obj1.isArray() && obj1.arrayGetLength() >= 6) {
+ bool decodeOk = true;
+ Object obj2;
+ xMin = (obj2 = obj1.arrayGet(0), obj2.getNum(&decodeOk));
+ xMax = (obj2 = obj1.arrayGet(1), obj2.getNum(&decodeOk));
xMul = (xMax - xMin) / (pow(2.0, coordBits) - 1);
- yMin = obj1.arrayGet(2, &obj2)->getNum();
- obj2.free();
- yMax = obj1.arrayGet(3, &obj2)->getNum();
- obj2.free();
+ yMin = (obj2 = obj1.arrayGet(2), obj2.getNum(&decodeOk));
+ yMax = (obj2 = obj1.arrayGet(3), obj2.getNum(&decodeOk));
yMul = (yMax - yMin) / (pow(2.0, coordBits) - 1);
for (i = 0; 5 + 2*i < obj1.arrayGetLength() && i < gfxColorMaxComps; ++i) {
- cMin[i] = obj1.arrayGet(4 + 2*i, &obj2)->getNum();
- obj2.free();
- cMax[i] = obj1.arrayGet(5 + 2*i, &obj2)->getNum();
- obj2.free();
+ cMin[i] = (obj2 = obj1.arrayGet(4 + 2*i), obj2.getNum(&decodeOk));
+ cMax[i] = (obj2 = obj1.arrayGet(5 + 2*i), obj2.getNum(&decodeOk));
cMul[i] = (cMax[i] - cMin[i]) / (double)((1 << compBits) - 1);
}
nComps = i;
+
+ if (!decodeOk) {
+ error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary");
+ return nullptr;
+ }
} else {
error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary");
- goto err2;
+ return nullptr;
}
- obj1.free();
- if (!dict->lookup("Function", &obj1)->isNull()) {
+ obj1 = dict->lookup("Function");
+ if (!obj1.isNull()) {
if (obj1.isArray()) {
nFuncsA = obj1.arrayGetLength();
if (nFuncsA > gfxColorMaxComps) {
error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary");
- goto err1;
+ return nullptr;
}
for (i = 0; i < nFuncsA; ++i) {
- obj1.arrayGet(i, &obj2);
+ Object obj2 = obj1.arrayGet(i);
if (!(funcsA[i] = Function::parse(&obj2))) {
- obj1.free();
- obj2.free();
- goto err1;
+ return nullptr;
}
- obj2.free();
}
} else {
nFuncsA = 1;
if (!(funcsA[0] = Function::parse(&obj1))) {
- obj1.free();
- goto err1;
+ return nullptr;
}
}
} else {
nFuncsA = 0;
}
- obj1.free();
nPatchesA = 0;
patchesA = NULL;
@@ -5462,7 +5255,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 1:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[0][3];
p->y[0][0] = patchesA[nPatchesA-1].y[0][3];
@@ -5497,7 +5290,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 2:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[3][3];
p->y[0][0] = patchesA[nPatchesA-1].y[3][3];
@@ -5532,7 +5325,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 3:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[3][0];
p->y[0][0] = patchesA[nPatchesA-1].y[3][0];
@@ -5610,7 +5403,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 1:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[0][3];
p->y[0][0] = patchesA[nPatchesA-1].y[0][3];
@@ -5653,7 +5446,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 2:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[3][3];
p->y[0][0] = patchesA[nPatchesA-1].y[3][3];
@@ -5696,7 +5489,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
break;
case 3:
if (nPatchesA == 0) {
- goto err1;
+ return nullptr;
}
p->x[0][0] = patchesA[nPatchesA-1].x[3][0];
p->y[0][0] = patchesA[nPatchesA-1].y[3][0];
@@ -5794,14 +5587,9 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
funcsA, nFuncsA);
if (!shading->init(res, dict, out, state)) {
delete shading;
- return NULL;
+ return nullptr;
}
return shading;
-
- err2:
- obj1.free();
- err1:
- return NULL;
}
void GfxPatchMeshShading::getParameterizedColor(double t, GfxColor *color) {
@@ -5830,7 +5618,6 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
int maxPixel, indexHigh;
Guchar *indexedLookup;
Function *sepFunc;
- Object obj;
double x[gfxColorMaxComps];
double y[gfxColorMaxComps];
int i, j, k;
@@ -5872,18 +5659,16 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
nComps = colorSpace->getNComps();
}
for (i = 0; i < nComps; ++i) {
- decode->arrayGet(2*i, &obj);
+ Object obj = decode->arrayGet(2*i);
if (!obj.isNum()) {
- goto err2;
+ goto err1;
}
decodeLow[i] = obj.getNum();
- obj.free();
- decode->arrayGet(2*i+1, &obj);
+ obj = decode->arrayGet(2*i+1);
if (!obj.isNum()) {
- goto err2;
+ goto err1;
}
decodeRange[i] = obj.getNum() - decodeLow[i];
- obj.free();
}
} else {
goto err1;
@@ -5988,8 +5773,6 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
return;
- err2:
- obj.free();
err1:
ok = gFalse;
}
@@ -7313,7 +7096,6 @@ GfxState *GfxState::restore() {
}
GBool GfxState::parseBlendMode(Object *obj, GfxBlendMode *mode) {
- Object obj2;
int i, j;
if (obj->isName()) {
@@ -7326,19 +7108,16 @@ GBool GfxState::parseBlendMode(Object *obj, GfxBlendMode *mode) {
return gFalse;
} else if (obj->isArray()) {
for (i = 0; i < obj->arrayGetLength(); ++i) {
- obj->arrayGet(i, &obj2);
+ Object obj2 = obj->arrayGet(i);
if (!obj2.isName()) {
- obj2.free();
return gFalse;
}
for (j = 0; j < nGfxBlendModeNames; ++j) {
if (!strcmp(obj2.getName(), gfxBlendModeNames[j].name)) {
- obj2.free();
*mode = gfxBlendModeNames[j].mode;
return gTrue;
}
}
- obj2.free();
}
*mode = gfxBlendNormal;
return gTrue;