diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-02-01 06:11:18 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-02-01 06:11:18 +0000 |
commit | 4f9de1dfebdc66d367d730252d6f224d37e96ee6 (patch) | |
tree | 3750421fabf3aa8a8e1f4f6d5558d489e9d4fe02 /Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc | |
parent | 9d694205709f79666458dc2ee685767b28bcd9ac (diff) |
xpdf 4.03
git-svn-id: svn://tug.org/texlive/trunk@57588 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc | 104 |
1 files changed, 101 insertions, 3 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc index 60b5f577054..5e9991e1b97 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc @@ -101,6 +101,7 @@ static const char *gfxColorSpaceModeNames[] = { GfxColorSpace::GfxColorSpace() { overprintMask = 0x0f; + defaultColorSpace = gFalse; } GfxColorSpace::~GfxColorSpace() { @@ -2683,6 +2684,11 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse( "Missing or invalid BitsPerCoordinate in shading dictionary"); goto err2; } + if (coordBits <= 0 || coordBits > 32) { + error(errSyntaxError, -1, + "Invalid BitsPerCoordinate in shading dictionary"); + goto err2; + } obj1.free(); if (dict->lookup("BitsPerComponent", &obj1)->isInt()) { compBits = obj1.getInt(); @@ -2691,6 +2697,11 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse( "Missing or invalid BitsPerComponent in shading dictionary"); goto err2; } + if (compBits <= 0 || compBits > 16) { + error(errSyntaxError, -1, + "Invalid BitsPerComponent in shading dictionary"); + goto err2; + } obj1.free(); flagBits = vertsPerRow = 0; // make gcc happy if (typeA == 4) { @@ -2701,6 +2712,10 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse( "Missing or invalid BitsPerFlag in shading dictionary"); goto err2; } + if (flagBits < 2 || flagBits > 8) { + error(errSyntaxError, -1, "Invalid BitsPerFlag in shading dictionary"); + goto err2; + } obj1.free(); } else { if (dict->lookup("VerticesPerRow", &obj1)->isInt()) { @@ -2711,6 +2726,11 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse( goto err2; } obj1.free(); + if (vertsPerRow < 2) { + error(errSyntaxError, -1, + "Invalid VerticesPerRow in shading dictionary"); + goto err2; + } } if (dict->lookup("Decode", &obj1)->isArray() && obj1.arrayGetLength() >= 6) { @@ -2911,6 +2931,34 @@ void GfxGouraudTriangleShading::getTriangle( } } +void GfxGouraudTriangleShading::getBBox(double *xMin, double *yMin, + double *xMax, double *yMax) { + double xxMin = 0; + double yyMin = 0; + double xxMax = 0; + double yyMax = 0; + if (nVertices > 0) { + xxMin = xxMax = vertices[0].x; + yyMin = yyMax = vertices[0].y; + } + for (int i = 1; i < nVertices; ++i) { + if (vertices[i].x < xxMin) { + xxMin = vertices[i].x; + } else if (vertices[i].x > xxMax) { + xxMax = vertices[i].x; + } + if (vertices[i].y < yyMin) { + yyMin = vertices[i].y; + } else if (vertices[i].y > yyMax) { + yyMax = vertices[i].y; + } + } + *xMin = xxMin; + *yMin = yyMin; + *xMax = xxMax; + *yMax = yyMax; +} + void GfxGouraudTriangleShading::getColor(double *in, GfxColor *out) { double c[gfxColorMaxComps]; int i; @@ -2996,6 +3044,10 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, Object obj1, obj2; int i, j; + nPatchesA = 0; + patchesA = NULL; + patchesSize = 0; + if (dict->lookup("BitsPerCoordinate", &obj1)->isInt()) { coordBits = obj1.getInt(); } else { @@ -3003,6 +3055,11 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, "Missing or invalid BitsPerCoordinate in shading dictionary"); goto err2; } + if (coordBits <= 0 || coordBits > 32) { + error(errSyntaxError, -1, + "Invalid BitsPerCoordinate in shading dictionary"); + goto err2; + } obj1.free(); if (dict->lookup("BitsPerComponent", &obj1)->isInt()) { compBits = obj1.getInt(); @@ -3011,6 +3068,11 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, "Missing or invalid BitsPerComponent in shading dictionary"); goto err2; } + if (compBits <= 0 || compBits > 16) { + error(errSyntaxError, -1, + "Invalid BitsPerComponent in shading dictionary"); + goto err2; + } obj1.free(); if (dict->lookup("BitsPerFlag", &obj1)->isInt()) { flagBits = obj1.getInt(); @@ -3019,6 +3081,10 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, "Missing or invalid BitsPerFlag in shading dictionary"); goto err2; } + if (flagBits < 2 || flagBits > 8) { + error(errSyntaxError, -1, "Invalid BitsPerFlag in shading dictionary"); + goto err2; + } obj1.free(); if (dict->lookup("Decode", &obj1)->isArray() && obj1.arrayGetLength() >= 6) { @@ -3076,9 +3142,6 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, } obj1.free(); - nPatchesA = 0; - patchesA = NULL; - patchesSize = 0; bitBuf = new GfxShadingBitBuf(str); while (1) { if (!bitBuf->getBits(flagBits, &flag)) { @@ -3506,6 +3569,9 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, err2: obj1.free(); err1: + if (patchesA) { + gfree(patchesA); + } return NULL; } @@ -3513,6 +3579,38 @@ GfxShading *GfxPatchMeshShading::copy() { return new GfxPatchMeshShading(this); } +void GfxPatchMeshShading::getBBox(double *xMin, double *yMin, + double *xMax, double *yMax) { + double xxMin = 0; + double yyMin = 0; + double xxMax = 0; + double yyMax = 0; + if (nPatches > 0) { + xxMin = patches[0].x[0][0]; + yyMin = patches[0].y[0][0]; + } + for (int i = 0; i < nPatches; ++i) { + for (int j = 0; j < 4; ++j) { + for (int k = 0; k < 4; ++k) { + if (patches[i].x[j][k] < xxMin) { + xxMin = patches[i].x[j][k]; + } else if (patches[i].x[j][k] > xxMax) { + xxMax = patches[i].x[j][k]; + } + if (patches[i].y[j][k] < yyMin) { + yyMin = patches[i].y[j][k]; + } else if (patches[i].y[j][k] > yyMax) { + yyMax = patches[i].y[j][k]; + } + } + } + } + *xMin = xxMin; + *yMin = yyMin; + *xMax = xxMax; + *yMax = yyMax; +} + void GfxPatchMeshShading::getColor(double *in, GfxColor *out) { double c[gfxColorMaxComps]; int i; |