summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2011-10-04 17:41:16 +0200
committerAlbert Astals Cid <aacid@kde.org>2011-10-04 17:41:16 +0200
commitf8182f6152acf20622bd6baa9f064905d2d5a9ff (patch)
tree72242389403b4ee0fb8cfe787caaaef05d3bdf45
parent329f04570f1cff337adf5639c867587bf3a57bfd (diff)
recursion stuff in GfxColorSpace merged
-rw-r--r--ALL_DIFF220
1 files changed, 1 insertions, 219 deletions
diff --git a/ALL_DIFF b/ALL_DIFF
index 889358e..009449b 100644
--- a/ALL_DIFF
+++ b/ALL_DIFF
@@ -10935,18 +10935,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
GfxColorSpace::~GfxColorSpace() {
}
--GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
-+GfxColorSpace *GfxColorSpace::parse(Object *csObj, int recursion) {
- GfxColorSpace *cs;
- Object obj1;
-
-+ if (recursion > colorSpaceRecursionLimit) {
-+ error(errSyntaxError, -1, "Loop detected in color space objects");
-+ return NULL;
-+ }
- cs = NULL;
- if (csObj->isName()) {
- if (csObj->isName("DeviceGray") || csObj->isName("G")) {
@@ -107,9 +120,9 @@
} else if (csObj->isName("Pattern")) {
cs = new GfxPatternColorSpace(NULL);
@@ -10958,49 +10946,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
csObj->arrayGet(0, &obj1);
if (obj1.isName("DeviceGray") || obj1.isName("G")) {
cs = new GfxDeviceGrayColorSpace();
-@@ -118,27 +131,27 @@
- } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
- cs = new GfxDeviceCMYKColorSpace();
- } else if (obj1.isName("CalGray")) {
- cs = GfxCalGrayColorSpace::parse(csObj->getArray());
- } else if (obj1.isName("CalRGB")) {
- cs = GfxCalRGBColorSpace::parse(csObj->getArray());
- } else if (obj1.isName("Lab")) {
- cs = GfxLabColorSpace::parse(csObj->getArray());
- } else if (obj1.isName("ICCBased")) {
-- cs = GfxICCBasedColorSpace::parse(csObj->getArray());
-+ cs = GfxICCBasedColorSpace::parse(csObj->getArray(), recursion);
- } else if (obj1.isName("Indexed") || obj1.isName("I")) {
-- cs = GfxIndexedColorSpace::parse(csObj->getArray());
-+ cs = GfxIndexedColorSpace::parse(csObj->getArray(), recursion);
- } else if (obj1.isName("Separation")) {
-- cs = GfxSeparationColorSpace::parse(csObj->getArray());
-+ cs = GfxSeparationColorSpace::parse(csObj->getArray(), recursion);
- } else if (obj1.isName("DeviceN")) {
-- cs = GfxDeviceNColorSpace::parse(csObj->getArray());
-+ cs = GfxDeviceNColorSpace::parse(csObj->getArray(), recursion);
- } else if (obj1.isName("Pattern")) {
-- cs = GfxPatternColorSpace::parse(csObj->getArray());
-+ cs = GfxPatternColorSpace::parse(csObj->getArray(), recursion);
- } else {
-- error(-1, "Bad color space");
-+ error(errSyntaxError, -1, "Bad color space");
- }
- obj1.free();
- } else {
- error(errSyntaxError, -1, "Bad color space - expected name or array");
- }
- return cs;
- }
-@@ -800,7 +831,7 @@
- return cs;
- }
-
--GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
-+GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, int recursion) {
- GfxICCBasedColorSpace *cs;
- Ref iccProfileStreamA;
- int nCompsA;
@@ -819,26 +854,27 @@
obj1.free();
arr->get(1, &obj1);
@@ -11029,11 +10974,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
+ nCompsA = 4;
}
if (dict->lookup("Alternate", &obj2)->isNull() ||
-- !(altA = GfxColorSpace::parse(&obj2))) {
-+ !(altA = GfxColorSpace::parse(&obj2, recursion + 1))) {
- switch (nCompsA) {
- case 1:
- altA = new GfxDeviceGrayColorSpace();
@@ -927,6 +964,7 @@
indexHigh = indexHighA;
lookup = (Guchar *)gmallocn((indexHigh + 1) * base->getNComps(),
@@ -11051,26 +10991,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
GfxIndexedColorSpace *cs;
GfxColorSpace *baseA;
int indexHighA;
-@@ -953,17 +991,17 @@
- int n, i, j;
-
- if (arr->getLength() != 4) {
- error(errSyntaxError, -1, "Bad Indexed color space");
- goto err1;
- }
- arr->get(1, &obj1);
-- if (!(baseA = GfxColorSpace::parse(&obj1))) {
-- error(-1, "Bad Indexed color space (base color space)");
-+ if (!(baseA = GfxColorSpace::parse(&obj1, recursion + 1))) {
-+ error(errSyntaxError, -1, "Bad Indexed color space (base color space)");
- goto err2;
- }
- obj1.free();
- if (!arr->get(2, &obj1)->isInt()) {
- error(errSyntaxError, -1, "Bad Indexed color space (hival)");
- delete baseA;
- goto err2;
- }
@@ -986,8 +1025,9 @@
for (i = 0; i <= indexHighA; ++i) {
for (j = 0; j < n; ++j) {
@@ -11133,31 +11053,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
}
//~ handle the 'All' and 'None' colorants
--GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr) {
-+GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, int recursion) {
- GfxSeparationColorSpace *cs;
- GString *nameA;
- GfxColorSpace *altA;
-@@ -1095,18 +1159,18 @@
- Object obj1;
-
- if (arr->getLength() != 4) {
- error(errSyntaxError, -1, "Bad Separation color space");
- goto err1;
- }
- if (!arr->get(1, &obj1)->isName()) {
- error(errSyntaxError, -1, "Bad Separation color space (name)");
- goto err2;
- }
- nameA = new GString(obj1.getName());
- obj1.free();
- arr->get(2, &obj1);
-- if (!(altA = GfxColorSpace::parse(&obj1))) {
-+ if (!(altA = GfxColorSpace::parse(&obj1, recursion + 1))) {
- error(errSyntaxError, -1, "Bad Separation color space (alternate color space)");
- goto err3;
- }
- obj1.free();
@@ -1179,12 +1245,51 @@
//------------------------------------------------------------------------
@@ -11229,21 +11124,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
}
//~ handle the 'None' colorant
--GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr) {
-+GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, int recursion) {
- GfxDeviceNColorSpace *cs;
- int nCompsA;
- GString *namesA[gfxColorMaxComps];
-@@ -1244,8 +1343,9 @@
- }
- obj1.free();
- arr->get(2, &obj1);
-- if (!(altA = GfxColorSpace::parse(&obj1))) {
-+ if (!(altA = GfxColorSpace::parse(&obj1, recursion + 1))) {
- error(errSyntaxError, -1, "Bad DeviceN color space (alternate color space)");
- goto err3;
- }
- obj1.free();
@@ -1254,14 +1354,7 @@
goto err4;
}
@@ -11260,29 +11140,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
return cs;
err4:
-@@ -1348,20 +1442,20 @@
- (GfxColorSpace *)NULL);
- }
-
--GfxColorSpace *GfxPatternColorSpace::parse(Array *arr) {
-+GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, int recursion) {
- GfxPatternColorSpace *cs;
- GfxColorSpace *underA;
- Object obj1;
-
- if (arr->getLength() != 1 && arr->getLength() != 2) {
- error(errSyntaxError, -1, "Bad Pattern color space");
- return NULL;
- }
- underA = NULL;
- if (arr->getLength() == 2) {
- arr->get(1, &obj1);
-- if (!(underA = GfxColorSpace::parse(&obj1))) {
-+ if (!(underA = GfxColorSpace::parse(&obj1, recursion + 1))) {
- error(errSyntaxError, -1, "Bad Pattern color space (underlying color space)");
- obj1.free();
- return NULL;
- }
@@ -3187,7 +3299,7 @@
GfxIndexedColorSpace *indexedCS;
GfxSeparationColorSpace *sepCS;
@@ -11683,15 +11540,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.cc xpdf-3.03/xpdf/GfxState.cc
diff -ru xpdf-3.02/xpdf/GfxState.h xpdf-3.03/xpdf/GfxState.h
--- xpdf-3.02/xpdf/GfxState.h 2007-02-27 23:05:52.000000000 +0100
+++ xpdf-3.03/xpdf/GfxState.h 2011-08-15 23:08:53.000000000 +0200
-@@ -138,7 +140,7 @@
- virtual GfxColorSpaceMode getMode() = 0;
-
- // Construct a color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Object *csObj);
-+ static GfxColorSpace *parse(Object *csObj, int recursion = 0);
-
- // Convert to gray, RGB, or CMYK.
- virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
@@ -160,13 +162,18 @@
// mark the page (e.g., the "None" colorant).
virtual GBool isNonMarking() { return gFalse; }
@@ -11712,62 +11560,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.h xpdf-3.03/xpdf/GfxState.h
};
//------------------------------------------------------------------------
-@@ -204,7 +211,7 @@
- virtual GfxColorSpaceMode getMode() { return csCalGray; }
-
- // Construct a CalGray color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-@@ -264,7 +271,7 @@
- virtual GfxColorSpaceMode getMode() { return csCalRGB; }
-
- // Construct a CalRGB color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-@@ -328,7 +335,7 @@
- virtual GfxColorSpaceMode getMode() { return csLab; }
-
- // Construct a Lab color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-@@ -374,7 +381,7 @@
- virtual GfxColorSpaceMode getMode() { return csICCBased; }
-
- // Construct an ICCBased color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-@@ -410,8 +417,8 @@
- virtual GfxColorSpace *copy();
- virtual GfxColorSpaceMode getMode() { return csIndexed; }
-
-- // Construct a Lab color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ // Construct an Indexed color space. Returns NULL if unsuccessful.
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-@@ -450,7 +457,7 @@
- virtual GfxColorSpaceMode getMode() { return csSeparation; }
-
- // Construct a Separation color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -468,6 +475,10 @@
private:
@@ -11791,8 +11583,7 @@ diff -ru xpdf-3.02/xpdf/GfxState.h xpdf-3.03/xpdf/GfxState.h
virtual GfxColorSpaceMode getMode() { return csDeviceN; }
// Construct a DeviceN color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
+ static GfxColorSpace *parse(Array *arr, int recursion);
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -11807,15 +11598,6 @@ diff -ru xpdf-3.02/xpdf/GfxState.h xpdf-3.03/xpdf/GfxState.h
int nComps; // number of components
GString // colorant names
*names[gfxColorMaxComps];
-@@ -526,7 +542,7 @@
- virtual GfxColorSpaceMode getMode() { return csPattern; }
-
- // Construct a Pattern color space. Returns NULL if unsuccessful.
-- static GfxColorSpace *parse(Array *arr);
-+ static GfxColorSpace *parse(Array *arr, int recursion);
-
- virtual void getGray(GfxColor *color, GfxGray *gray);
- virtual void getRGB(GfxColor *color, GfxRGB *rgb);
@@ -878,6 +894,11 @@
void getCMYK(Guchar *x, GfxCMYK *cmyk);
void getColor(Guchar *x, GfxColor *color);