idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
6,400
void vnc_write_s32(VncState *vs, int32_t value) { vnc_write_u32(vs, *(uint32_t *)&value); }
DoS
0
void vnc_write_s32(VncState *vs, int32_t value) { vnc_write_u32(vs, *(uint32_t *)&value); }
@@ -2026,6 +2026,16 @@ static void set_pixel_format(VncState *vs, return; } + switch (bits_per_pixel) { + case 8: + case 16: + case 32: + break; + default: + vnc_client_error(vs); + return; + } + vs->client_pf.rmax = red_max; vs->client_pf.rbits = hweight_long(red_max); vs->client_pf.rshift = red_shift;
CWE-264
null
null
6,401
void vnc_write_u16(VncState *vs, uint16_t value) { uint8_t buf[2]; buf[0] = (value >> 8) & 0xFF; buf[1] = value & 0xFF; vnc_write(vs, buf, 2); }
DoS
0
void vnc_write_u16(VncState *vs, uint16_t value) { uint8_t buf[2]; buf[0] = (value >> 8) & 0xFF; buf[1] = value & 0xFF; vnc_write(vs, buf, 2); }
@@ -2026,6 +2026,16 @@ static void set_pixel_format(VncState *vs, return; } + switch (bits_per_pixel) { + case 8: + case 16: + case 32: + break; + default: + vnc_client_error(vs); + return; + } + vs->client_pf.rmax = red_max; vs->client_pf.rbits = hweight_long(red_max); vs->client_pf.rshift = red_shift;
CWE-264
null
null
6,402
void vnc_write_u32(VncState *vs, uint32_t value) { uint8_t buf[4]; buf[0] = (value >> 24) & 0xFF; buf[1] = (value >> 16) & 0xFF; buf[2] = (value >> 8) & 0xFF; buf[3] = value & 0xFF; vnc_write(vs, buf, 4); }
DoS
0
void vnc_write_u32(VncState *vs, uint32_t value) { uint8_t buf[4]; buf[0] = (value >> 24) & 0xFF; buf[1] = (value >> 16) & 0xFF; buf[2] = (value >> 8) & 0xFF; buf[3] = value & 0xFF; vnc_write(vs, buf, 4); }
@@ -2026,6 +2026,16 @@ static void set_pixel_format(VncState *vs, return; } + switch (bits_per_pixel) { + case 8: + case 16: + case 32: + break; + default: + vnc_client_error(vs); + return; + } + vs->client_pf.rmax = red_max; vs->client_pf.rbits = hweight_long(red_max); vs->client_pf.rshift = red_shift;
CWE-264
null
null
6,403
void vnc_write_u8(VncState *vs, uint8_t value) { vnc_write(vs, (char *)&value, 1); }
DoS
0
void vnc_write_u8(VncState *vs, uint8_t value) { vnc_write(vs, (char *)&value, 1); }
@@ -2026,6 +2026,16 @@ static void set_pixel_format(VncState *vs, return; } + switch (bits_per_pixel) { + case 8: + case 16: + case 32: + break; + default: + vnc_client_error(vs); + return; + } + vs->client_pf.rmax = red_max; vs->client_pf.rbits = hweight_long(red_max); vs->client_pf.rshift = red_shift;
CWE-264
null
null
6,404
FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA): FoFiBase(fileA, lenA, freeFileDataA) { name = NULL; encoding = NULL; parsed = gFalse; }
DoS Exec Code Mem. Corr. Bypass
0
FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA): FoFiBase(fileA, lenA, freeFileDataA) { name = NULL; encoding = NULL; parsed = gFalse; }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,405
char **FoFiType1::getEncoding() { if (!parsed) { parse(); } return encoding; }
DoS Exec Code Mem. Corr. Bypass
0
char **FoFiType1::getEncoding() { if (!parsed) { parse(); } return encoding; }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,406
char *FoFiType1::getName() { if (!parsed) { parse(); } return name; }
DoS Exec Code Mem. Corr. Bypass
0
char *FoFiType1::getName() { if (!parsed) { parse(); } return name; }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,407
FoFiType1 *FoFiType1::load(char *fileName) { char *fileA; int lenA; if (!(fileA = FoFiBase::readFile(fileName, &lenA))) { return NULL; } return new FoFiType1(fileA, lenA, gTrue); }
DoS Exec Code Mem. Corr. Bypass
0
FoFiType1 *FoFiType1::load(char *fileName) { char *fileA; int lenA; if (!(fileA = FoFiBase::readFile(fileName, &lenA))) { return NULL; } return new FoFiType1(fileA, lenA, gTrue); }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,408
FoFiType1 *FoFiType1::make(char *fileA, int lenA) { return new FoFiType1(fileA, lenA, gFalse); }
DoS Exec Code Mem. Corr. Bypass
0
FoFiType1 *FoFiType1::make(char *fileA, int lenA) { return new FoFiType1(fileA, lenA, gFalse); }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,409
void FoFiType1::writeEncoded(char **newEncoding, FoFiOutputFunc outputFunc, void *outputStream) { char buf[512]; char *line, *line2, *p; int i; for (line = (char *)file; line && strncmp(line, "/Encoding", 9); line = getNextLine(line)) ; if (!line) { (*outputFunc)(outputStream, (char *)file, len); return; } (*outputFunc)(outputStream, (char *)file, line - (char *)file); (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); (*outputFunc)(outputStream, "0 1 255 {1 index exch /.notdef put} for\n", 40); for (i = 0; i < 256; ++i) { if (newEncoding[i]) { sprintf(buf, "dup %d /%s put\n", i, newEncoding[i]); (*outputFunc)(outputStream, buf, strlen(buf)); } } (*outputFunc)(outputStream, "readonly def\n", 13); if (!strncmp(line, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line); } else { p = line + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } if (line) { for (line2 = line, i = 0; i < 20 && line2 && strncmp(line2, "/Encoding", 9); line2 = getNextLine(line2), ++i) ; if (i < 20 && line2) { (*outputFunc)(outputStream, line, line2 - line); if (!strncmp(line2, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line2); } else { p = line2 + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } } if (line) { (*outputFunc)(outputStream, line, ((char *)file + len) - line); } } }
DoS Exec Code Mem. Corr. Bypass
0
void FoFiType1::writeEncoded(char **newEncoding, FoFiOutputFunc outputFunc, void *outputStream) { char buf[512]; char *line, *line2, *p; int i; for (line = (char *)file; line && strncmp(line, "/Encoding", 9); line = getNextLine(line)) ; if (!line) { (*outputFunc)(outputStream, (char *)file, len); return; } (*outputFunc)(outputStream, (char *)file, line - (char *)file); (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); (*outputFunc)(outputStream, "0 1 255 {1 index exch /.notdef put} for\n", 40); for (i = 0; i < 256; ++i) { if (newEncoding[i]) { sprintf(buf, "dup %d /%s put\n", i, newEncoding[i]); (*outputFunc)(outputStream, buf, strlen(buf)); } } (*outputFunc)(outputStream, "readonly def\n", 13); if (!strncmp(line, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line); } else { p = line + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } if (line) { for (line2 = line, i = 0; i < 20 && line2 && strncmp(line2, "/Encoding", 9); line2 = getNextLine(line2), ++i) ; if (i < 20 && line2) { (*outputFunc)(outputStream, line, line2 - line); if (!strncmp(line2, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line2); } else { p = line2 + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } } if (line) { (*outputFunc)(outputStream, line, ((char *)file + len) - line); } } }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,410
FoFiType1::~FoFiType1() { int i; if (name) { gfree(name); } if (encoding && encoding != fofiType1StandardEncoding) { for (i = 0; i < 256; ++i) { gfree(encoding[i]); } gfree(encoding); } }
DoS Exec Code Mem. Corr. Bypass
0
FoFiType1::~FoFiType1() { int i; if (name) { gfree(name); } if (encoding && encoding != fofiType1StandardEncoding) { for (i = 0; i < 256; ++i) { gfree(encoding[i]); } gfree(encoding); } }
@@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <ubanus@users.sf.net> // @@ -31,6 +31,7 @@ #include <stdlib.h> #include <string.h> #include "goo/gmem.h" +#include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" #include "poppler/Error.h" @@ -243,7 +244,7 @@ void FoFiType1::parse() { code = code * 8 + (*p2 - '0'); } } - if (code < 256) { + if (likely(code < 256 && code >= 0)) { for (p = p2; *p == ' ' || *p == '\t'; ++p) ; if (*p == '/') { ++p;
CWE-20
null
null
6,411
GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) : gStateCache(2, xref) { Object obj1, obj2; Ref r; if (resDict) { fonts = NULL; resDict->lookupNF("Font", &obj1); if (obj1.isRef()) { obj1.fetch(xref, &obj2); if (obj2.isDict()) { r = obj1.getRef(); fonts = new GfxFontDict(xref, &r, obj2.getDict()); } obj2.free(); } else if (obj1.isDict()) { fonts = new GfxFontDict(xref, NULL, obj1.getDict()); } obj1.free(); resDict->lookup("XObject", &xObjDict); resDict->lookup("ColorSpace", &colorSpaceDict); resDict->lookup("Pattern", &patternDict); resDict->lookup("Shading", &shadingDict); resDict->lookup("ExtGState", &gStateDict); resDict->lookup("Properties", &propertiesDict); } else { fonts = NULL; xObjDict.initNull(); colorSpaceDict.initNull(); patternDict.initNull(); shadingDict.initNull(); gStateDict.initNull(); propertiesDict.initNull(); } next = nextA; }
DoS
0
GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) : gStateCache(2, xref) { Object obj1, obj2; Ref r; if (resDict) { fonts = NULL; resDict->lookupNF("Font", &obj1); if (obj1.isRef()) { obj1.fetch(xref, &obj2); if (obj2.isDict()) { r = obj1.getRef(); fonts = new GfxFontDict(xref, &r, obj2.getDict()); } obj2.free(); } else if (obj1.isDict()) { fonts = new GfxFontDict(xref, NULL, obj1.getDict()); } obj1.free(); resDict->lookup("XObject", &xObjDict); resDict->lookup("ColorSpace", &colorSpaceDict); resDict->lookup("Pattern", &patternDict); resDict->lookup("Shading", &shadingDict); resDict->lookup("ExtGState", &gStateDict); resDict->lookup("Properties", &propertiesDict); } else { fonts = NULL; xObjDict.initNull(); colorSpaceDict.initNull(); patternDict.initNull(); shadingDict.initNull(); gStateDict.initNull(); propertiesDict.initNull(); } next = nextA; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,412
int Gfx::bottomGuard() { return stateGuards[stateGuards.size()-1]; }
DoS
0
int Gfx::bottomGuard() { return stateGuards[stateGuards.size()-1]; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,413
Stream *Gfx::buildImageStream() { Object dict; Object obj; char *key; Stream *str; dict.initDict(xref); parser->getObj(&obj); while (!obj.isCmd("ID") && !obj.isEOF()) { if (!obj.isName()) { error(getPos(), "Inline image dictionary key must be a name object"); obj.free(); } else { key = copyString(obj.getName()); obj.free(); parser->getObj(&obj); if (obj.isEOF() || obj.isError()) { gfree(key); break; } dict.dictAdd(key, &obj); } parser->getObj(&obj); } if (obj.isEOF()) { error(getPos(), "End of file in inline image"); obj.free(); dict.free(); return NULL; } obj.free(); if (parser->getStream()) { str = new EmbedStream(parser->getStream(), &dict, gFalse, 0); str = str->addFilters(&dict); } else { str = NULL; dict.free(); } return str; }
DoS
0
Stream *Gfx::buildImageStream() { Object dict; Object obj; char *key; Stream *str; dict.initDict(xref); parser->getObj(&obj); while (!obj.isCmd("ID") && !obj.isEOF()) { if (!obj.isName()) { error(getPos(), "Inline image dictionary key must be a name object"); obj.free(); } else { key = copyString(obj.getName()); obj.free(); parser->getObj(&obj); if (obj.isEOF() || obj.isError()) { gfree(key); break; } dict.dictAdd(key, &obj); } parser->getObj(&obj); } if (obj.isEOF()) { error(getPos(), "End of file in inline image"); obj.free(); dict.free(); return NULL; } obj.free(); if (parser->getStream()) { str = new EmbedStream(parser->getStream(), &dict, gFalse, 0); str = str->addFilters(&dict); } else { str = NULL; dict.free(); } return str; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,414
GBool Gfx::contentIsHidden() { MarkedContentStack *mc = mcStack; bool hidden = mc && mc->ocSuppressed; while (!hidden && mc && mc->next) { mc = mc->next; hidden = mc->ocSuppressed; } return hidden; }
DoS
0
GBool Gfx::contentIsHidden() { MarkedContentStack *mc = mcStack; bool hidden = mc && mc->ocSuppressed; while (!hidden && mc && mc->next) { mc = mc->next; hidden = mc->ocSuppressed; } return hidden; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,415
void Gfx::display(Object *obj, GBool topLevel) { Object obj2; int i; if (obj->isArray()) { for (i = 0; i < obj->arrayGetLength(); ++i) { obj->arrayGet(i, &obj2); if (!obj2.isStream()) { error(-1, "Weird page contents"); obj2.free(); return; } obj2.free(); } } else if (!obj->isStream()) { error(-1, "Weird page contents"); return; } parser = new Parser(xref, new Lexer(xref, obj), gFalse); go(topLevel); delete parser; parser = NULL; }
DoS
0
void Gfx::display(Object *obj, GBool topLevel) { Object obj2; int i; if (obj->isArray()) { for (i = 0; i < obj->arrayGetLength(); ++i) { obj->arrayGet(i, &obj2); if (!obj2.isStream()) { error(-1, "Weird page contents"); obj2.free(); return; } obj2.free(); } } else if (!obj->isStream()) { error(-1, "Weird page contents"); return; } parser = new Parser(xref, new Lexer(xref, obj), gFalse); go(topLevel); delete parser; parser = NULL; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,416
void Gfx::doAxialShFill(GfxAxialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, x1, y1; double dx, dy, mul; GBool dxZero, dyZero; double bboxIntersections[4]; double tMin, tMax, tx, ty; double s[4], sMin, sMax, tmp; double ux0, uy0, ux1, uy1, vx0, vy0, vx1, vy1; double t0, t1, tt; double ta[axialMaxSplits + 1]; int next[axialMaxSplits + 1]; GfxColor color0, color1; int nComps; int i, j, k; GBool needExtend = gTrue; state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); shading->getCoords(&x0, &y0, &x1, &y1); dx = x1 - x0; dy = y1 - y0; dxZero = fabs(dx) < 0.01; dyZero = fabs(dy) < 0.01; if (dxZero && dyZero) { tMin = tMax = 0; } else { mul = 1 / (dx * dx + dy * dy); bboxIntersections[0] = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; bboxIntersections[1] = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; bboxIntersections[2] = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; bboxIntersections[3] = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; bubbleSort(bboxIntersections); tMin = bboxIntersections[0]; tMax = bboxIntersections[3]; if (tMin < 0 && !shading->getExtend0()) { tMin = 0; } if (tMax > 1 && !shading->getExtend1()) { tMax = 1; } } if (out->useShadedFills() && out->axialShadedFill(state, shading, tMin, tMax)) { return; } t0 = shading->getDomain0(); t1 = shading->getDomain1(); nComps = shading->getColorSpace()->getNComps(); ta[0] = tMin; next[0] = axialMaxSplits / 2; ta[axialMaxSplits / 2] = 0.5 * (tMin + tMax); next[axialMaxSplits / 2] = axialMaxSplits; ta[axialMaxSplits] = tMax; if (tMin < 0) { tt = t0; } else if (tMin > 1) { tt = t1; } else { tt = t0 + (t1 - t0) * tMin; } shading->getColor(tt, &color0); if (out->useFillColorStop()) { state->setFillColor(&color0); out->updateFillColorStop(state, 0); } tx = x0 + tMin * dx; ty = y0 + tMin * dy; if (dxZero && dyZero) { sMin = sMax = 0; } else if (dxZero) { sMin = (xMin - tx) / -dy; sMax = (xMax - tx) / -dy; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else if (dyZero) { sMin = (yMin - ty) / dx; sMax = (yMax - ty) / dx; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else { s[0] = (yMin - ty) / dx; s[1] = (yMax - ty) / dx; s[2] = (xMin - tx) / -dy; s[3] = (xMax - tx) / -dy; bubbleSort(s); sMin = s[1]; sMax = s[2]; } ux0 = tx - sMin * dy; uy0 = ty + sMin * dx; vx0 = tx - sMax * dy; vy0 = ty + sMax * dx; i = 0; bool doneBBox1, doneBBox2; if (dxZero && dyZero) { doneBBox1 = doneBBox2 = true; } else { doneBBox1 = bboxIntersections[1] < tMin; doneBBox2 = bboxIntersections[2] > tMax; } needExtend = !out->axialShadedSupportExtend(state, shading); while (i < axialMaxSplits) { j = next[i]; while (j > i + 1) { if (ta[j] < 0) { tt = t0; } else if (ta[j] > 1) { tt = t1; } else { tt = t0 + (t1 - t0) * ta[j]; } shading->getColor(tt, &color1); if (isSameGfxColor(color1, color0, nComps, axialColorDelta)) { if (!doneBBox1 && ta[i] < bboxIntersections[1] && ta[j] > bboxIntersections[1]) { int teoricalj = (int) ((bboxIntersections[1] - tMin) * axialMaxSplits / (tMax - tMin)); if (teoricalj <= i) teoricalj = i + 1; if (teoricalj < j) { next[i] = teoricalj; next[teoricalj] = j; } else { teoricalj = j; } ta[teoricalj] = bboxIntersections[1]; j = teoricalj; doneBBox1 = true; } if (!doneBBox2 && ta[i] < bboxIntersections[2] && ta[j] > bboxIntersections[2]) { int teoricalj = (int) ((bboxIntersections[2] - tMin) * axialMaxSplits / (tMax - tMin)); if (teoricalj <= i) teoricalj = i + 1; if (teoricalj < j) { next[i] = teoricalj; next[teoricalj] = j; } else { teoricalj = j; } ta[teoricalj] = bboxIntersections[2]; j = teoricalj; doneBBox2 = true; } break; } k = (i + j) / 2; ta[k] = 0.5 * (ta[i] + ta[j]); next[i] = k; next[k] = j; j = k; } for (k = 0; k < nComps; ++k) { color0.c[k] = (color0.c[k] + color1.c[k]) / 2; } tx = x0 + ta[j] * dx; ty = y0 + ta[j] * dy; if (dxZero && dyZero) { sMin = sMax = 0; } else if (dxZero) { sMin = (xMin - tx) / -dy; sMax = (xMax - tx) / -dy; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else if (dyZero) { sMin = (yMin - ty) / dx; sMax = (yMax - ty) / dx; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else { s[0] = (yMin - ty) / dx; s[1] = (yMax - ty) / dx; s[2] = (xMin - tx) / -dy; s[3] = (xMax - tx) / -dy; bubbleSort(s); sMin = s[1]; sMax = s[2]; } ux1 = tx - sMin * dy; uy1 = ty + sMin * dx; vx1 = tx - sMax * dy; vy1 = ty + sMax * dx; state->setFillColor(&color0); if (out->useFillColorStop()) out->updateFillColorStop(state, (ta[j] - tMin)/(tMax - tMin)); else out->updateFillColor(state); if (needExtend) { state->moveTo(ux0, uy0); state->lineTo(vx0, vy0); state->lineTo(vx1, vy1); state->lineTo(ux1, uy1); state->closePath(); } if (!out->useFillColorStop()) { if (!contentIsHidden()) out->fill(state); state->clearPath(); } ux0 = ux1; uy0 = uy1; vx0 = vx1; vy0 = vy1; color0 = color1; i = next[i]; } if (out->useFillColorStop()) { if (!needExtend) { state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); } if (!contentIsHidden()) out->fill(state); state->clearPath(); } }
DoS
0
void Gfx::doAxialShFill(GfxAxialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, x1, y1; double dx, dy, mul; GBool dxZero, dyZero; double bboxIntersections[4]; double tMin, tMax, tx, ty; double s[4], sMin, sMax, tmp; double ux0, uy0, ux1, uy1, vx0, vy0, vx1, vy1; double t0, t1, tt; double ta[axialMaxSplits + 1]; int next[axialMaxSplits + 1]; GfxColor color0, color1; int nComps; int i, j, k; GBool needExtend = gTrue; state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); shading->getCoords(&x0, &y0, &x1, &y1); dx = x1 - x0; dy = y1 - y0; dxZero = fabs(dx) < 0.01; dyZero = fabs(dy) < 0.01; if (dxZero && dyZero) { tMin = tMax = 0; } else { mul = 1 / (dx * dx + dy * dy); bboxIntersections[0] = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; bboxIntersections[1] = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; bboxIntersections[2] = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; bboxIntersections[3] = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; bubbleSort(bboxIntersections); tMin = bboxIntersections[0]; tMax = bboxIntersections[3]; if (tMin < 0 && !shading->getExtend0()) { tMin = 0; } if (tMax > 1 && !shading->getExtend1()) { tMax = 1; } } if (out->useShadedFills() && out->axialShadedFill(state, shading, tMin, tMax)) { return; } t0 = shading->getDomain0(); t1 = shading->getDomain1(); nComps = shading->getColorSpace()->getNComps(); ta[0] = tMin; next[0] = axialMaxSplits / 2; ta[axialMaxSplits / 2] = 0.5 * (tMin + tMax); next[axialMaxSplits / 2] = axialMaxSplits; ta[axialMaxSplits] = tMax; if (tMin < 0) { tt = t0; } else if (tMin > 1) { tt = t1; } else { tt = t0 + (t1 - t0) * tMin; } shading->getColor(tt, &color0); if (out->useFillColorStop()) { state->setFillColor(&color0); out->updateFillColorStop(state, 0); } tx = x0 + tMin * dx; ty = y0 + tMin * dy; if (dxZero && dyZero) { sMin = sMax = 0; } else if (dxZero) { sMin = (xMin - tx) / -dy; sMax = (xMax - tx) / -dy; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else if (dyZero) { sMin = (yMin - ty) / dx; sMax = (yMax - ty) / dx; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else { s[0] = (yMin - ty) / dx; s[1] = (yMax - ty) / dx; s[2] = (xMin - tx) / -dy; s[3] = (xMax - tx) / -dy; bubbleSort(s); sMin = s[1]; sMax = s[2]; } ux0 = tx - sMin * dy; uy0 = ty + sMin * dx; vx0 = tx - sMax * dy; vy0 = ty + sMax * dx; i = 0; bool doneBBox1, doneBBox2; if (dxZero && dyZero) { doneBBox1 = doneBBox2 = true; } else { doneBBox1 = bboxIntersections[1] < tMin; doneBBox2 = bboxIntersections[2] > tMax; } needExtend = !out->axialShadedSupportExtend(state, shading); while (i < axialMaxSplits) { j = next[i]; while (j > i + 1) { if (ta[j] < 0) { tt = t0; } else if (ta[j] > 1) { tt = t1; } else { tt = t0 + (t1 - t0) * ta[j]; } shading->getColor(tt, &color1); if (isSameGfxColor(color1, color0, nComps, axialColorDelta)) { if (!doneBBox1 && ta[i] < bboxIntersections[1] && ta[j] > bboxIntersections[1]) { int teoricalj = (int) ((bboxIntersections[1] - tMin) * axialMaxSplits / (tMax - tMin)); if (teoricalj <= i) teoricalj = i + 1; if (teoricalj < j) { next[i] = teoricalj; next[teoricalj] = j; } else { teoricalj = j; } ta[teoricalj] = bboxIntersections[1]; j = teoricalj; doneBBox1 = true; } if (!doneBBox2 && ta[i] < bboxIntersections[2] && ta[j] > bboxIntersections[2]) { int teoricalj = (int) ((bboxIntersections[2] - tMin) * axialMaxSplits / (tMax - tMin)); if (teoricalj <= i) teoricalj = i + 1; if (teoricalj < j) { next[i] = teoricalj; next[teoricalj] = j; } else { teoricalj = j; } ta[teoricalj] = bboxIntersections[2]; j = teoricalj; doneBBox2 = true; } break; } k = (i + j) / 2; ta[k] = 0.5 * (ta[i] + ta[j]); next[i] = k; next[k] = j; j = k; } for (k = 0; k < nComps; ++k) { color0.c[k] = (color0.c[k] + color1.c[k]) / 2; } tx = x0 + ta[j] * dx; ty = y0 + ta[j] * dy; if (dxZero && dyZero) { sMin = sMax = 0; } else if (dxZero) { sMin = (xMin - tx) / -dy; sMax = (xMax - tx) / -dy; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else if (dyZero) { sMin = (yMin - ty) / dx; sMax = (yMax - ty) / dx; if (sMin > sMax) { tmp = sMin; sMin = sMax; sMax = tmp; } } else { s[0] = (yMin - ty) / dx; s[1] = (yMax - ty) / dx; s[2] = (xMin - tx) / -dy; s[3] = (xMax - tx) / -dy; bubbleSort(s); sMin = s[1]; sMax = s[2]; } ux1 = tx - sMin * dy; uy1 = ty + sMin * dx; vx1 = tx - sMax * dy; vy1 = ty + sMax * dx; state->setFillColor(&color0); if (out->useFillColorStop()) out->updateFillColorStop(state, (ta[j] - tMin)/(tMax - tMin)); else out->updateFillColor(state); if (needExtend) { state->moveTo(ux0, uy0); state->lineTo(vx0, vy0); state->lineTo(vx1, vy1); state->lineTo(ux1, uy1); state->closePath(); } if (!out->useFillColorStop()) { if (!contentIsHidden()) out->fill(state); state->clearPath(); } ux0 = ux1; uy0 = uy1; vx0 = vx1; vy0 = vy1; color0 = color1; i = next[i]; } if (out->useFillColorStop()) { if (!needExtend) { state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); } if (!contentIsHidden()) out->fill(state); state->clearPath(); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,417
void Gfx::doEndPath() { if (state->isCurPt() && clip != clipNone) { state->clip(); if (clip == clipNormal) { out->clip(state); } else { out->eoClip(state); } } clip = clipNone; state->clearPath(); }
DoS
0
void Gfx::doEndPath() { if (state->isCurPt() && clip != clipNone) { state->clip(); if (clip == clipNormal) { out->clip(state); } else { out->eoClip(state); } } clip = clipNone; state->clearPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,418
void Gfx::doForm(Object *str) { Dict *dict; GBool transpGroup, isolated, knockout; GfxColorSpace *blendingColorSpace; Object matrixObj, bboxObj; double m[6], bbox[4]; Object resObj; Dict *resDict; Object obj1, obj2, obj3; int i; if (formDepth > 20) { return; } dict = str->streamGetDict(); dict->lookup("FormType", &obj1); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(getPos(), "Unknown form type"); } obj1.free(); dict->lookup("BBox", &bboxObj); if (!bboxObj.isArray()) { bboxObj.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { bboxObj.arrayGet(i, &obj1); bbox[i] = obj1.getNum(); obj1.free(); } bboxObj.free(); dict->lookup("Matrix", &matrixObj); if (matrixObj.isArray()) { for (i = 0; i < 6; ++i) { matrixObj.arrayGet(i, &obj1); m[i] = obj1.getNum(); obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } matrixObj.free(); dict->lookup("Resources", &resObj); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; transpGroup = isolated = knockout = gFalse; blendingColorSpace = NULL; if (dict->lookup("Group", &obj1)->isDict()) { if (obj1.dictLookup("S", &obj2)->isName("Transparency")) { transpGroup = gTrue; if (!obj1.dictLookup("CS", &obj3)->isNull()) { blendingColorSpace = GfxColorSpace::parse(&obj3, this); } obj3.free(); if (obj1.dictLookup("I", &obj3)->isBool()) { isolated = obj3.getBool(); } obj3.free(); if (obj1.dictLookup("K", &obj3)->isBool()) { knockout = obj3.getBool(); } obj3.free(); } obj2.free(); } obj1.free(); ++formDepth; doForm1(str, resDict, m, bbox, transpGroup, gFalse, blendingColorSpace, isolated, knockout); --formDepth; if (blendingColorSpace) { delete blendingColorSpace; } resObj.free(); }
DoS
0
void Gfx::doForm(Object *str) { Dict *dict; GBool transpGroup, isolated, knockout; GfxColorSpace *blendingColorSpace; Object matrixObj, bboxObj; double m[6], bbox[4]; Object resObj; Dict *resDict; Object obj1, obj2, obj3; int i; if (formDepth > 20) { return; } dict = str->streamGetDict(); dict->lookup("FormType", &obj1); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(getPos(), "Unknown form type"); } obj1.free(); dict->lookup("BBox", &bboxObj); if (!bboxObj.isArray()) { bboxObj.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { bboxObj.arrayGet(i, &obj1); bbox[i] = obj1.getNum(); obj1.free(); } bboxObj.free(); dict->lookup("Matrix", &matrixObj); if (matrixObj.isArray()) { for (i = 0; i < 6; ++i) { matrixObj.arrayGet(i, &obj1); m[i] = obj1.getNum(); obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } matrixObj.free(); dict->lookup("Resources", &resObj); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; transpGroup = isolated = knockout = gFalse; blendingColorSpace = NULL; if (dict->lookup("Group", &obj1)->isDict()) { if (obj1.dictLookup("S", &obj2)->isName("Transparency")) { transpGroup = gTrue; if (!obj1.dictLookup("CS", &obj3)->isNull()) { blendingColorSpace = GfxColorSpace::parse(&obj3, this); } obj3.free(); if (obj1.dictLookup("I", &obj3)->isBool()) { isolated = obj3.getBool(); } obj3.free(); if (obj1.dictLookup("K", &obj3)->isBool()) { knockout = obj3.getBool(); } obj3.free(); } obj2.free(); } obj1.free(); ++formDepth; doForm1(str, resDict, m, bbox, transpGroup, gFalse, blendingColorSpace, isolated, knockout); --formDepth; if (blendingColorSpace) { delete blendingColorSpace; } resObj.free(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,419
void Gfx::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox, GBool transpGroup, GBool softMask, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, GBool alpha, Function *transferFunc, GfxColor *backdropColor) { Parser *oldParser; double oldBaseMatrix[6]; int i; pushResources(resDict); saveState(); state->clearPath(); oldParser = parser; state->concatCTM(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); out->updateCTM(state, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); state->moveTo(bbox[0], bbox[1]); state->lineTo(bbox[2], bbox[1]); state->lineTo(bbox[2], bbox[3]); state->lineTo(bbox[0], bbox[3]); state->closePath(); state->clip(); out->clip(state); state->clearPath(); if (softMask || transpGroup) { if (state->getBlendMode() != gfxBlendNormal) { state->setBlendMode(gfxBlendNormal); out->updateBlendMode(state); } if (state->getFillOpacity() != 1) { state->setFillOpacity(1); out->updateFillOpacity(state); } if (state->getStrokeOpacity() != 1) { state->setStrokeOpacity(1); out->updateStrokeOpacity(state); } out->clearSoftMask(state); out->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, softMask); } for (i = 0; i < 6; ++i) { oldBaseMatrix[i] = baseMatrix[i]; baseMatrix[i] = state->getCTM()[i]; } GfxState *stateBefore = state; display(str, gFalse); if (stateBefore != state) { if (state->isParentState(stateBefore)) { error(-1, "There's a form with more q than Q, trying to fix"); while (stateBefore != state) { restoreState(); } } else { error(-1, "There's a form with more Q than q"); } } if (softMask || transpGroup) { out->endTransparencyGroup(state); } for (i = 0; i < 6; ++i) { baseMatrix[i] = oldBaseMatrix[i]; } parser = oldParser; restoreState(); popResources(); if (softMask) { out->setSoftMask(state, bbox, alpha, transferFunc, backdropColor); } else if (transpGroup) { out->paintTransparencyGroup(state, bbox); } return; }
DoS
0
void Gfx::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox, GBool transpGroup, GBool softMask, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, GBool alpha, Function *transferFunc, GfxColor *backdropColor) { Parser *oldParser; double oldBaseMatrix[6]; int i; pushResources(resDict); saveState(); state->clearPath(); oldParser = parser; state->concatCTM(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); out->updateCTM(state, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); state->moveTo(bbox[0], bbox[1]); state->lineTo(bbox[2], bbox[1]); state->lineTo(bbox[2], bbox[3]); state->lineTo(bbox[0], bbox[3]); state->closePath(); state->clip(); out->clip(state); state->clearPath(); if (softMask || transpGroup) { if (state->getBlendMode() != gfxBlendNormal) { state->setBlendMode(gfxBlendNormal); out->updateBlendMode(state); } if (state->getFillOpacity() != 1) { state->setFillOpacity(1); out->updateFillOpacity(state); } if (state->getStrokeOpacity() != 1) { state->setStrokeOpacity(1); out->updateStrokeOpacity(state); } out->clearSoftMask(state); out->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, softMask); } for (i = 0; i < 6; ++i) { oldBaseMatrix[i] = baseMatrix[i]; baseMatrix[i] = state->getCTM()[i]; } GfxState *stateBefore = state; display(str, gFalse); if (stateBefore != state) { if (state->isParentState(stateBefore)) { error(-1, "There's a form with more q than Q, trying to fix"); while (stateBefore != state) { restoreState(); } } else { error(-1, "There's a form with more Q than q"); } } if (softMask || transpGroup) { out->endTransparencyGroup(state); } for (i = 0; i < 6; ++i) { baseMatrix[i] = oldBaseMatrix[i]; } parser = oldParser; restoreState(); popResources(); if (softMask) { out->setSoftMask(state, bbox, alpha, transferFunc, backdropColor); } else if (transpGroup) { out->paintTransparencyGroup(state, bbox); } return; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,420
void Gfx::doFunctionShFill(GfxFunctionShading *shading) { double x0, y0, x1, y1; GfxColor colors[4]; if (out->useShadedFills() && out->functionShadedFill(state, shading)) { return; } shading->getDomain(&x0, &y0, &x1, &y1); shading->getColor(x0, y0, &colors[0]); shading->getColor(x0, y1, &colors[1]); shading->getColor(x1, y0, &colors[2]); shading->getColor(x1, y1, &colors[3]); doFunctionShFill1(shading, x0, y0, x1, y1, colors, 0); }
DoS
0
void Gfx::doFunctionShFill(GfxFunctionShading *shading) { double x0, y0, x1, y1; GfxColor colors[4]; if (out->useShadedFills() && out->functionShadedFill(state, shading)) { return; } shading->getDomain(&x0, &y0, &x1, &y1); shading->getColor(x0, y0, &colors[0]); shading->getColor(x0, y1, &colors[1]); shading->getColor(x1, y0, &colors[2]); shading->getColor(x1, y1, &colors[3]); doFunctionShFill1(shading, x0, y0, x1, y1, colors, 0); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,421
void Gfx::doGouraudTriangleShFill(GfxGouraudTriangleShading *shading) { double x0, y0, x1, y1, x2, y2; GfxColor color0, color1, color2; int i; for (i = 0; i < shading->getNTriangles(); ++i) { shading->getTriangle(i, &x0, &y0, &color0, &x1, &y1, &color1, &x2, &y2, &color2); gouraudFillTriangle(x0, y0, &color0, x1, y1, &color1, x2, y2, &color2, shading->getColorSpace()->getNComps(), 0); } }
DoS
0
void Gfx::doGouraudTriangleShFill(GfxGouraudTriangleShading *shading) { double x0, y0, x1, y1, x2, y2; GfxColor color0, color1, color2; int i; for (i = 0; i < shading->getNTriangles(); ++i) { shading->getTriangle(i, &x0, &y0, &color0, &x1, &y1, &color1, &x2, &y2, &color2); gouraudFillTriangle(x0, y0, &color0, x1, y1, &color1, x2, y2, &color2, shading->getColorSpace()->getNComps(), 0); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,422
void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { Dict *dict, *maskDict; int width, height; int bits, maskBits; GBool interpolate; StreamColorSpaceMode csMode; GBool mask; GBool invert; GfxColorSpace *colorSpace, *maskColorSpace; GfxImageColorMap *colorMap, *maskColorMap; Object maskObj, smaskObj; GBool haveColorKeyMask, haveExplicitMask, haveSoftMask; int maskColors[2*gfxColorMaxComps]; int maskWidth, maskHeight; GBool maskInvert; GBool maskInterpolate; Stream *maskStr; Object obj1, obj2; int i; bits = 0; csMode = streamCSNone; str->getImageParams(&bits, &csMode); dict = str->getDict(); dict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("W", &obj1); } if (obj1.isInt()) width = obj1.getInt(); else if (obj1.isReal()) width = (int)obj1.getReal(); else goto err2; obj1.free(); dict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("H", &obj1); } if (obj1.isInt()) height = obj1.getInt(); else if (obj1.isReal()) height = (int)obj1.getReal(); else goto err2; obj1.free(); if (width < 1 || height < 1) goto err1; dict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("I", &obj1); } if (obj1.isBool()) interpolate = obj1.getBool(); else interpolate = gFalse; obj1.free(); maskInterpolate = gFalse; dict->lookup("ImageMask", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("IM", &obj1); } mask = gFalse; if (obj1.isBool()) mask = obj1.getBool(); else if (!obj1.isNull()) goto err2; obj1.free(); if (bits == 0) { dict->lookup("BitsPerComponent", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("BPC", &obj1); } if (obj1.isInt()) { bits = obj1.getInt(); } else if (mask) { bits = 1; } else { goto err2; } obj1.free(); } if (mask) { if (bits != 1) goto err1; invert = gFalse; dict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("D", &obj1); } if (obj1.isArray()) { obj1.arrayGet(0, &obj2); if (obj2.isNum() && obj2.getNum() >= 0.9) invert = gTrue; obj2.free(); } else if (!obj1.isNull()) { goto err2; } obj1.free(); if (!contentIsHidden()) { out->drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg); if (out->fillMaskCSPattern(state)) { maskHaveCSPattern = gTrue; doPatternFill(gTrue); out->endMaskClip(state); maskHaveCSPattern = gFalse; } } } else { dict->lookup("ColorSpace", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("CS", &obj1); } if (obj1.isName() && inlineImg) { res->lookupColorSpace(obj1.getName(), &obj2); if (!obj2.isNull()) { obj1.free(); obj1 = obj2; } else { obj2.free(); } } if (!obj1.isNull()) { colorSpace = GfxColorSpace::parse(&obj1, this); } else if (csMode == streamCSDeviceGray) { colorSpace = new GfxDeviceGrayColorSpace(); } else if (csMode == streamCSDeviceRGB) { colorSpace = new GfxDeviceRGBColorSpace(); } else if (csMode == streamCSDeviceCMYK) { colorSpace = new GfxDeviceCMYKColorSpace(); } else { colorSpace = NULL; } obj1.free(); if (!colorSpace) { goto err1; } dict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("D", &obj1); } colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); obj1.free(); if (!colorMap->isOk()) { delete colorMap; goto err1; } haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse; maskStr = NULL; // make gcc happy maskWidth = maskHeight = 0; // make gcc happy maskInvert = gFalse; // make gcc happy maskColorMap = NULL; // make gcc happy dict->lookup("Mask", &maskObj); dict->lookup("SMask", &smaskObj); if (smaskObj.isStream()) { if (inlineImg) { goto err1; } maskStr = smaskObj.getStream(); maskDict = smaskObj.streamGetDict(); maskDict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("W", &obj1); } if (!obj1.isInt()) { goto err2; } maskWidth = obj1.getInt(); obj1.free(); maskDict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("H", &obj1); } if (!obj1.isInt()) { goto err2; } maskHeight = obj1.getInt(); obj1.free(); maskDict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("I", &obj1); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; obj1.free(); maskDict->lookup("BitsPerComponent", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("BPC", &obj1); } if (!obj1.isInt()) { goto err2; } maskBits = obj1.getInt(); obj1.free(); maskDict->lookup("ColorSpace", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("CS", &obj1); } if (obj1.isName()) { res->lookupColorSpace(obj1.getName(), &obj2); if (!obj2.isNull()) { obj1.free(); obj1 = obj2; } else { obj2.free(); } } maskColorSpace = GfxColorSpace::parse(&obj1, this); obj1.free(); if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { goto err1; } maskDict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("D", &obj1); } maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); obj1.free(); if (!maskColorMap->isOk()) { delete maskColorMap; goto err1; } haveSoftMask = gTrue; } else if (maskObj.isArray()) { for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) { maskObj.arrayGet(i, &obj1); if (obj1.isInt()) { maskColors[i] = obj1.getInt(); } else if (obj1.isReal()) { error(-1, "Mask entry should be an integer but it's a real, trying to use it"); maskColors[i] = (int) obj1.getReal(); } else { error(-1, "Mask entry should be an integer but it's of type %d", obj1.getType()); obj1.free(); goto err1; } obj1.free(); } haveColorKeyMask = gTrue; } else if (maskObj.isStream()) { if (inlineImg) { goto err1; } maskStr = maskObj.getStream(); maskDict = maskObj.streamGetDict(); maskDict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("W", &obj1); } if (!obj1.isInt()) { goto err2; } maskWidth = obj1.getInt(); obj1.free(); maskDict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("H", &obj1); } if (!obj1.isInt()) { goto err2; } maskHeight = obj1.getInt(); obj1.free(); maskDict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("I", &obj1); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; obj1.free(); maskDict->lookup("ImageMask", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("IM", &obj1); } if (!obj1.isBool() || !obj1.getBool()) { goto err2; } obj1.free(); maskInvert = gFalse; maskDict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("D", &obj1); } if (obj1.isArray()) { obj1.arrayGet(0, &obj2); if (obj2.isNum() && obj2.getNum() >= 0.9) { maskInvert = gTrue; } obj2.free(); } else if (!obj1.isNull()) { goto err2; } obj1.free(); haveExplicitMask = gTrue; } if (haveSoftMask) { if (!contentIsHidden()) { out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); } delete maskColorMap; } else if (haveExplicitMask && !contentIsHidden ()) { out->drawMaskedImage(state, ref, str, width, height, colorMap, interpolate, maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate); } else if (!contentIsHidden()) { out->drawImage(state, ref, str, width, height, colorMap, interpolate, haveColorKeyMask ? maskColors : (int *)NULL, inlineImg); } delete colorMap; maskObj.free(); smaskObj.free(); } if ((i = width * height) > 1000) { i = 1000; } updateLevel += i; return; err2: obj1.free(); err1: error(getPos(), "Bad image parameters"); }
DoS
0
void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { Dict *dict, *maskDict; int width, height; int bits, maskBits; GBool interpolate; StreamColorSpaceMode csMode; GBool mask; GBool invert; GfxColorSpace *colorSpace, *maskColorSpace; GfxImageColorMap *colorMap, *maskColorMap; Object maskObj, smaskObj; GBool haveColorKeyMask, haveExplicitMask, haveSoftMask; int maskColors[2*gfxColorMaxComps]; int maskWidth, maskHeight; GBool maskInvert; GBool maskInterpolate; Stream *maskStr; Object obj1, obj2; int i; bits = 0; csMode = streamCSNone; str->getImageParams(&bits, &csMode); dict = str->getDict(); dict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("W", &obj1); } if (obj1.isInt()) width = obj1.getInt(); else if (obj1.isReal()) width = (int)obj1.getReal(); else goto err2; obj1.free(); dict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("H", &obj1); } if (obj1.isInt()) height = obj1.getInt(); else if (obj1.isReal()) height = (int)obj1.getReal(); else goto err2; obj1.free(); if (width < 1 || height < 1) goto err1; dict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("I", &obj1); } if (obj1.isBool()) interpolate = obj1.getBool(); else interpolate = gFalse; obj1.free(); maskInterpolate = gFalse; dict->lookup("ImageMask", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("IM", &obj1); } mask = gFalse; if (obj1.isBool()) mask = obj1.getBool(); else if (!obj1.isNull()) goto err2; obj1.free(); if (bits == 0) { dict->lookup("BitsPerComponent", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("BPC", &obj1); } if (obj1.isInt()) { bits = obj1.getInt(); } else if (mask) { bits = 1; } else { goto err2; } obj1.free(); } if (mask) { if (bits != 1) goto err1; invert = gFalse; dict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("D", &obj1); } if (obj1.isArray()) { obj1.arrayGet(0, &obj2); if (obj2.isNum() && obj2.getNum() >= 0.9) invert = gTrue; obj2.free(); } else if (!obj1.isNull()) { goto err2; } obj1.free(); if (!contentIsHidden()) { out->drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg); if (out->fillMaskCSPattern(state)) { maskHaveCSPattern = gTrue; doPatternFill(gTrue); out->endMaskClip(state); maskHaveCSPattern = gFalse; } } } else { dict->lookup("ColorSpace", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("CS", &obj1); } if (obj1.isName() && inlineImg) { res->lookupColorSpace(obj1.getName(), &obj2); if (!obj2.isNull()) { obj1.free(); obj1 = obj2; } else { obj2.free(); } } if (!obj1.isNull()) { colorSpace = GfxColorSpace::parse(&obj1, this); } else if (csMode == streamCSDeviceGray) { colorSpace = new GfxDeviceGrayColorSpace(); } else if (csMode == streamCSDeviceRGB) { colorSpace = new GfxDeviceRGBColorSpace(); } else if (csMode == streamCSDeviceCMYK) { colorSpace = new GfxDeviceCMYKColorSpace(); } else { colorSpace = NULL; } obj1.free(); if (!colorSpace) { goto err1; } dict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); dict->lookup("D", &obj1); } colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); obj1.free(); if (!colorMap->isOk()) { delete colorMap; goto err1; } haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse; maskStr = NULL; // make gcc happy maskWidth = maskHeight = 0; // make gcc happy maskInvert = gFalse; // make gcc happy maskColorMap = NULL; // make gcc happy dict->lookup("Mask", &maskObj); dict->lookup("SMask", &smaskObj); if (smaskObj.isStream()) { if (inlineImg) { goto err1; } maskStr = smaskObj.getStream(); maskDict = smaskObj.streamGetDict(); maskDict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("W", &obj1); } if (!obj1.isInt()) { goto err2; } maskWidth = obj1.getInt(); obj1.free(); maskDict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("H", &obj1); } if (!obj1.isInt()) { goto err2; } maskHeight = obj1.getInt(); obj1.free(); maskDict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("I", &obj1); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; obj1.free(); maskDict->lookup("BitsPerComponent", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("BPC", &obj1); } if (!obj1.isInt()) { goto err2; } maskBits = obj1.getInt(); obj1.free(); maskDict->lookup("ColorSpace", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("CS", &obj1); } if (obj1.isName()) { res->lookupColorSpace(obj1.getName(), &obj2); if (!obj2.isNull()) { obj1.free(); obj1 = obj2; } else { obj2.free(); } } maskColorSpace = GfxColorSpace::parse(&obj1, this); obj1.free(); if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { goto err1; } maskDict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("D", &obj1); } maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); obj1.free(); if (!maskColorMap->isOk()) { delete maskColorMap; goto err1; } haveSoftMask = gTrue; } else if (maskObj.isArray()) { for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) { maskObj.arrayGet(i, &obj1); if (obj1.isInt()) { maskColors[i] = obj1.getInt(); } else if (obj1.isReal()) { error(-1, "Mask entry should be an integer but it's a real, trying to use it"); maskColors[i] = (int) obj1.getReal(); } else { error(-1, "Mask entry should be an integer but it's of type %d", obj1.getType()); obj1.free(); goto err1; } obj1.free(); } haveColorKeyMask = gTrue; } else if (maskObj.isStream()) { if (inlineImg) { goto err1; } maskStr = maskObj.getStream(); maskDict = maskObj.streamGetDict(); maskDict->lookup("Width", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("W", &obj1); } if (!obj1.isInt()) { goto err2; } maskWidth = obj1.getInt(); obj1.free(); maskDict->lookup("Height", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("H", &obj1); } if (!obj1.isInt()) { goto err2; } maskHeight = obj1.getInt(); obj1.free(); maskDict->lookup("Interpolate", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("I", &obj1); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; obj1.free(); maskDict->lookup("ImageMask", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("IM", &obj1); } if (!obj1.isBool() || !obj1.getBool()) { goto err2; } obj1.free(); maskInvert = gFalse; maskDict->lookup("Decode", &obj1); if (obj1.isNull()) { obj1.free(); maskDict->lookup("D", &obj1); } if (obj1.isArray()) { obj1.arrayGet(0, &obj2); if (obj2.isNum() && obj2.getNum() >= 0.9) { maskInvert = gTrue; } obj2.free(); } else if (!obj1.isNull()) { goto err2; } obj1.free(); haveExplicitMask = gTrue; } if (haveSoftMask) { if (!contentIsHidden()) { out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); } delete maskColorMap; } else if (haveExplicitMask && !contentIsHidden ()) { out->drawMaskedImage(state, ref, str, width, height, colorMap, interpolate, maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate); } else if (!contentIsHidden()) { out->drawImage(state, ref, str, width, height, colorMap, interpolate, haveColorKeyMask ? maskColors : (int *)NULL, inlineImg); } delete colorMap; maskObj.free(); smaskObj.free(); } if ((i = width * height) > 1000) { i = 1000; } updateLevel += i; return; err2: obj1.free(); err1: error(getPos(), "Bad image parameters"); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,423
void Gfx::doPatchMeshShFill(GfxPatchMeshShading *shading) { int start, i; if (shading->getNPatches() > 128) { start = 3; } else if (shading->getNPatches() > 64) { start = 2; } else if (shading->getNPatches() > 16) { start = 1; } else { start = 0; } for (i = 0; i < shading->getNPatches(); ++i) { fillPatch(shading->getPatch(i), shading->getColorSpace()->getNComps(), start); } }
DoS
0
void Gfx::doPatchMeshShFill(GfxPatchMeshShading *shading) { int start, i; if (shading->getNPatches() > 128) { start = 3; } else if (shading->getNPatches() > 64) { start = 2; } else if (shading->getNPatches() > 16) { start = 1; } else { start = 0; } for (i = 0; i < shading->getNPatches(); ++i) { fillPatch(shading->getPatch(i), shading->getColorSpace()->getNComps(), start); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,424
void Gfx::doPatternFill(GBool eoFill) { GfxPattern *pattern; if (!out->needNonText()) { return; } if (!(pattern = state->getFillPattern())) { return; } switch (pattern->getType()) { case 1: doTilingPatternFill((GfxTilingPattern *)pattern, gFalse, eoFill); break; case 2: doShadingPatternFill((GfxShadingPattern *)pattern, gFalse, eoFill); break; default: error(getPos(), "Unimplemented pattern type (%d) in fill", pattern->getType()); break; } }
DoS
0
void Gfx::doPatternFill(GBool eoFill) { GfxPattern *pattern; if (!out->needNonText()) { return; } if (!(pattern = state->getFillPattern())) { return; } switch (pattern->getType()) { case 1: doTilingPatternFill((GfxTilingPattern *)pattern, gFalse, eoFill); break; case 2: doShadingPatternFill((GfxShadingPattern *)pattern, gFalse, eoFill); break; default: error(getPos(), "Unimplemented pattern type (%d) in fill", pattern->getType()); break; } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,425
void Gfx::doRadialShFill(GfxRadialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, r0, x1, y1, r1, t0, t1; int nComps; GfxColor colorA, colorB; double xa, ya, xb, yb, ra, rb; double ta, tb, sa, sb; double sz, xz, yz, sMin, sMax; GBool enclosed; int ia, ib, k, n; double *ctm; double theta, alpha, angle, t; GBool needExtend = gTrue; shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1); t0 = shading->getDomain0(); t1 = shading->getDomain1(); nComps = shading->getColorSpace()->getNComps(); if (x0 == x1 && y0 == y1) { enclosed = gTrue; theta = 0; // make gcc happy sz = 0; // make gcc happy } else if (r0 == r1) { enclosed = gFalse; theta = 0; sz = 0; // make gcc happy } else { sz = -r0 / (r1 - r0); xz = x0 + sz * (x1 - x0); yz = y0 + sz * (y1 - y0); enclosed = (xz - x0) * (xz - x0) + (yz - y0) * (yz - y0) <= r0 * r0; theta = asin(r0 / sqrt((x0 - xz) * (x0 - xz) + (y0 - yz) * (y0 - yz))); if (r0 > r1) { theta = -theta; } } if (enclosed) { alpha = 0; } else { alpha = atan2(y1 - y0, x1 - x0); } state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); if (enclosed) { sMin = 0; sMax = 1; } else { sMin = 1; sMax = 0; if ((x1 + r1) - (x0 + r0) != 0) { sa = (xMin - (x0 + r0)) / ((x1 + r1) - (x0 + r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((x1 - r1) - (x0 - r0) != 0) { sa = (xMax - (x0 - r0)) / ((x1 - r1) - (x0 - r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((y1 + r1) - (y0 + r0) != 0) { sa = (yMin - (y0 + r0)) / ((y1 + r1) - (y0 + r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((y1 - r1) - (y0 - r0) != 0) { sa = (yMax - (y0 - r0)) / ((y1 - r1) - (y0 - r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if (r0 < r1) { if (sMin < sz) { sMin = sz; } } else if (r0 > r1) { if (sMax > sz) { sMax = sz; } } if (!shading->getExtend0() && sMin < 0) { sMin = 0; } if (!shading->getExtend1() && sMax > 1) { sMax = 1; } } if (out->useShadedFills() && out->radialShadedFill(state, shading, sMin, sMax)) { return; } ctm = state->getCTM(); t = fabs(ctm[0]); if (fabs(ctm[1]) > t) { t = fabs(ctm[1]); } if (fabs(ctm[2]) > t) { t = fabs(ctm[2]); } if (fabs(ctm[3]) > t) { t = fabs(ctm[3]); } if (r0 > r1) { t *= r0; } else { t *= r1; } if (t < 1) { n = 3; } else { n = (int)(M_PI / acos(1 - 0.1 / t)); if (n < 3) { n = 3; } else if (n > 200) { n = 200; } } ia = 0; sa = sMin; ta = t0 + sa * (t1 - t0); xa = x0 + sa * (x1 - x0); ya = y0 + sa * (y1 - y0); ra = r0 + sa * (r1 - r0); if (ta < t0) { shading->getColor(t0, &colorA); } else if (ta > t1) { shading->getColor(t1, &colorA); } else { shading->getColor(ta, &colorA); } needExtend = !out->radialShadedSupportExtend(state, shading); while (ia < radialMaxSplits) { ib = radialMaxSplits; sb = sMax; tb = t0 + sb * (t1 - t0); if (tb < t0) { shading->getColor(t0, &colorB); } else if (tb > t1) { shading->getColor(t1, &colorB); } else { shading->getColor(tb, &colorB); } while (ib - ia > 1) { if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta) && ib < radialMaxSplits) { GfxColor colorC; int ic = (ia + ib) / 2; double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin); double tc = t0 + sc * (t1 - t0); if (tc < t0) { shading->getColor(t0, &colorC); } else if (tc > t1) { shading->getColor(t1, &colorC); } else { shading->getColor(tc, &colorC); } if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) break; } ib = (ia + ib) / 2; sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin); tb = t0 + sb * (t1 - t0); if (tb < t0) { shading->getColor(t0, &colorB); } else if (tb > t1) { shading->getColor(t1, &colorB); } else { shading->getColor(tb, &colorB); } } xb = x0 + sb * (x1 - x0); yb = y0 + sb * (y1 - y0); rb = r0 + sb * (r1 - r0); for (k = 0; k < nComps; ++k) { colorA.c[k] = (colorA.c[k] + colorB.c[k]) / 2; } state->setFillColor(&colorA); if (out->useFillColorStop()) out->updateFillColorStop(state, (sa - sMin)/(sMax - sMin)); else out->updateFillColor(state); if (needExtend) { if (enclosed) { state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); state->moveTo(xb + rb, yb); for (k = 1; k < n; ++k) { angle = -((double)k / (double)n) * 2 * M_PI; state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } state->closePath(); } else { state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), ya + ra * sin(alpha + theta + 0.5 * M_PI)); for (k = 0; k < n; ++k) { angle = alpha + theta + 0.5 * M_PI - ((double)k / (double)n) * (2 * theta + M_PI); state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } for (k = 0; k < n; ++k) { angle = alpha - theta - 0.5 * M_PI + ((double)k / (double)n) * (2 * theta - M_PI); state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), ya + ra * sin(alpha + theta + 0.5 * M_PI)); for (k = 0; k < n; ++k) { angle = alpha + theta + 0.5 * M_PI + ((double)k / (double)n) * (-2 * theta + M_PI); state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } for (k = 0; k < n; ++k) { angle = alpha - theta - 0.5 * M_PI + ((double)k / (double)n) * (2 * theta + M_PI); state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); } } if (!out->useFillColorStop()) { if (!contentIsHidden()) out->fill(state); state->clearPath(); } ia = ib; sa = sb; ta = tb; xa = xb; ya = yb; ra = rb; colorA = colorB; } if (out->useFillColorStop()) { state->setFillColor(&colorA); out->updateFillColorStop(state, (sb - sMin)/(sMax - sMin)); state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } if (!needExtend) return; if (enclosed) { if ((shading->getExtend0() && r0 <= r1) || (shading->getExtend1() && r1 < r0)) { if (r0 <= r1) { ta = t0; ra = r0; xa = x0; ya = y0; } else { ta = t1; ra = r1; xa = x1; ya = y1; } shading->getColor(ta, &colorA); state->setFillColor(&colorA); out->updateFillColor(state); state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } if ((shading->getExtend0() && r0 > r1) || (shading->getExtend1() && r1 >= r0)) { if (r0 > r1) { ta = t0; ra = r0; xa = x0; ya = y0; } else { ta = t1; ra = r1; xa = x1; ya = y1; } shading->getColor(ta, &colorA); state->setFillColor(&colorA); out->updateFillColor(state); state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } } }
DoS
0
void Gfx::doRadialShFill(GfxRadialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, r0, x1, y1, r1, t0, t1; int nComps; GfxColor colorA, colorB; double xa, ya, xb, yb, ra, rb; double ta, tb, sa, sb; double sz, xz, yz, sMin, sMax; GBool enclosed; int ia, ib, k, n; double *ctm; double theta, alpha, angle, t; GBool needExtend = gTrue; shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1); t0 = shading->getDomain0(); t1 = shading->getDomain1(); nComps = shading->getColorSpace()->getNComps(); if (x0 == x1 && y0 == y1) { enclosed = gTrue; theta = 0; // make gcc happy sz = 0; // make gcc happy } else if (r0 == r1) { enclosed = gFalse; theta = 0; sz = 0; // make gcc happy } else { sz = -r0 / (r1 - r0); xz = x0 + sz * (x1 - x0); yz = y0 + sz * (y1 - y0); enclosed = (xz - x0) * (xz - x0) + (yz - y0) * (yz - y0) <= r0 * r0; theta = asin(r0 / sqrt((x0 - xz) * (x0 - xz) + (y0 - yz) * (y0 - yz))); if (r0 > r1) { theta = -theta; } } if (enclosed) { alpha = 0; } else { alpha = atan2(y1 - y0, x1 - x0); } state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); if (enclosed) { sMin = 0; sMax = 1; } else { sMin = 1; sMax = 0; if ((x1 + r1) - (x0 + r0) != 0) { sa = (xMin - (x0 + r0)) / ((x1 + r1) - (x0 + r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((x1 - r1) - (x0 - r0) != 0) { sa = (xMax - (x0 - r0)) / ((x1 - r1) - (x0 - r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((y1 + r1) - (y0 + r0) != 0) { sa = (yMin - (y0 + r0)) / ((y1 + r1) - (y0 + r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if ((y1 - r1) - (y0 - r0) != 0) { sa = (yMax - (y0 - r0)) / ((y1 - r1) - (y0 - r0)); if (sa < sMin) { sMin = sa; } else if (sa > sMax) { sMax = sa; } } if (r0 < r1) { if (sMin < sz) { sMin = sz; } } else if (r0 > r1) { if (sMax > sz) { sMax = sz; } } if (!shading->getExtend0() && sMin < 0) { sMin = 0; } if (!shading->getExtend1() && sMax > 1) { sMax = 1; } } if (out->useShadedFills() && out->radialShadedFill(state, shading, sMin, sMax)) { return; } ctm = state->getCTM(); t = fabs(ctm[0]); if (fabs(ctm[1]) > t) { t = fabs(ctm[1]); } if (fabs(ctm[2]) > t) { t = fabs(ctm[2]); } if (fabs(ctm[3]) > t) { t = fabs(ctm[3]); } if (r0 > r1) { t *= r0; } else { t *= r1; } if (t < 1) { n = 3; } else { n = (int)(M_PI / acos(1 - 0.1 / t)); if (n < 3) { n = 3; } else if (n > 200) { n = 200; } } ia = 0; sa = sMin; ta = t0 + sa * (t1 - t0); xa = x0 + sa * (x1 - x0); ya = y0 + sa * (y1 - y0); ra = r0 + sa * (r1 - r0); if (ta < t0) { shading->getColor(t0, &colorA); } else if (ta > t1) { shading->getColor(t1, &colorA); } else { shading->getColor(ta, &colorA); } needExtend = !out->radialShadedSupportExtend(state, shading); while (ia < radialMaxSplits) { ib = radialMaxSplits; sb = sMax; tb = t0 + sb * (t1 - t0); if (tb < t0) { shading->getColor(t0, &colorB); } else if (tb > t1) { shading->getColor(t1, &colorB); } else { shading->getColor(tb, &colorB); } while (ib - ia > 1) { if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta) && ib < radialMaxSplits) { GfxColor colorC; int ic = (ia + ib) / 2; double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin); double tc = t0 + sc * (t1 - t0); if (tc < t0) { shading->getColor(t0, &colorC); } else if (tc > t1) { shading->getColor(t1, &colorC); } else { shading->getColor(tc, &colorC); } if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) break; } ib = (ia + ib) / 2; sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin); tb = t0 + sb * (t1 - t0); if (tb < t0) { shading->getColor(t0, &colorB); } else if (tb > t1) { shading->getColor(t1, &colorB); } else { shading->getColor(tb, &colorB); } } xb = x0 + sb * (x1 - x0); yb = y0 + sb * (y1 - y0); rb = r0 + sb * (r1 - r0); for (k = 0; k < nComps; ++k) { colorA.c[k] = (colorA.c[k] + colorB.c[k]) / 2; } state->setFillColor(&colorA); if (out->useFillColorStop()) out->updateFillColorStop(state, (sa - sMin)/(sMax - sMin)); else out->updateFillColor(state); if (needExtend) { if (enclosed) { state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); state->moveTo(xb + rb, yb); for (k = 1; k < n; ++k) { angle = -((double)k / (double)n) * 2 * M_PI; state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } state->closePath(); } else { state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), ya + ra * sin(alpha + theta + 0.5 * M_PI)); for (k = 0; k < n; ++k) { angle = alpha + theta + 0.5 * M_PI - ((double)k / (double)n) * (2 * theta + M_PI); state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } for (k = 0; k < n; ++k) { angle = alpha - theta - 0.5 * M_PI + ((double)k / (double)n) * (2 * theta - M_PI); state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); state->moveTo(xa + ra * cos(alpha + theta + 0.5 * M_PI), ya + ra * sin(alpha + theta + 0.5 * M_PI)); for (k = 0; k < n; ++k) { angle = alpha + theta + 0.5 * M_PI + ((double)k / (double)n) * (-2 * theta + M_PI); state->lineTo(xb + rb * cos(angle), yb + rb * sin(angle)); } for (k = 0; k < n; ++k) { angle = alpha - theta - 0.5 * M_PI + ((double)k / (double)n) * (2 * theta + M_PI); state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); } } if (!out->useFillColorStop()) { if (!contentIsHidden()) out->fill(state); state->clearPath(); } ia = ib; sa = sb; ta = tb; xa = xb; ya = yb; ra = rb; colorA = colorB; } if (out->useFillColorStop()) { state->setFillColor(&colorA); out->updateFillColorStop(state, (sb - sMin)/(sMax - sMin)); state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } if (!needExtend) return; if (enclosed) { if ((shading->getExtend0() && r0 <= r1) || (shading->getExtend1() && r1 < r0)) { if (r0 <= r1) { ta = t0; ra = r0; xa = x0; ya = y0; } else { ta = t1; ra = r1; xa = x1; ya = y1; } shading->getColor(ta, &colorA); state->setFillColor(&colorA); out->updateFillColor(state); state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } if ((shading->getExtend0() && r0 > r1) || (shading->getExtend1() && r1 >= r0)) { if (r0 > r1) { ta = t0; ra = r0; xa = x0; ya = y0; } else { ta = t1; ra = r1; xa = x1; ya = y1; } shading->getColor(ta, &colorA); state->setFillColor(&colorA); out->updateFillColor(state); state->moveTo(xMin, yMin); state->lineTo(xMin, yMax); state->lineTo(xMax, yMax); state->lineTo(xMax, yMin); state->closePath(); state->moveTo(xa + ra, ya); for (k = 1; k < n; ++k) { angle = ((double)k / (double)n) * 2 * M_PI; state->lineTo(xa + ra * cos(angle), ya + ra * sin(angle)); } state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,426
void Gfx::doShowText(GooString *s) { GfxFont *font; int wMode; double riseX, riseY; CharCode code; Unicode *u = NULL; double x, y, dx, dy, dx2, dy2, curX, curY, tdx, tdy, lineX, lineY; double originX, originY, tOriginX, tOriginY; double oldCTM[6], newCTM[6]; double *mat; Object charProc; Dict *resDict; Parser *oldParser; char *p; int len, n, uLen, nChars, nSpaces, i; font = state->getFont(); wMode = font->getWMode(); if (out->useDrawChar()) { out->beginString(state, s); } if (font->getType() == fontType3 && out->interpretType3Chars()) { mat = state->getCTM(); for (i = 0; i < 6; ++i) { oldCTM[i] = mat[i]; } mat = state->getTextMat(); newCTM[0] = mat[0] * oldCTM[0] + mat[1] * oldCTM[2]; newCTM[1] = mat[0] * oldCTM[1] + mat[1] * oldCTM[3]; newCTM[2] = mat[2] * oldCTM[0] + mat[3] * oldCTM[2]; newCTM[3] = mat[2] * oldCTM[1] + mat[3] * oldCTM[3]; mat = font->getFontMatrix(); newCTM[0] = mat[0] * newCTM[0] + mat[1] * newCTM[2]; newCTM[1] = mat[0] * newCTM[1] + mat[1] * newCTM[3]; newCTM[2] = mat[2] * newCTM[0] + mat[3] * newCTM[2]; newCTM[3] = mat[2] * newCTM[1] + mat[3] * newCTM[3]; newCTM[0] *= state->getFontSize(); newCTM[1] *= state->getFontSize(); newCTM[2] *= state->getFontSize(); newCTM[3] *= state->getFontSize(); newCTM[0] *= state->getHorizScaling(); newCTM[2] *= state->getHorizScaling(); state->textTransformDelta(0, state->getRise(), &riseX, &riseY); curX = state->getCurX(); curY = state->getCurY(); lineX = state->getLineX(); lineY = state->getLineY(); oldParser = parser; p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx, &dy, &originX, &originY); dx = dx * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dx += state->getWordSpace(); } dx *= state->getHorizScaling(); dy *= state->getFontSize(); state->textTransformDelta(dx, dy, &tdx, &tdy); state->transform(curX + riseX, curY + riseY, &x, &y); saveState(); state->setCTM(newCTM[0], newCTM[1], newCTM[2], newCTM[3], x, y); out->updateCTM(state, 1, 0, 0, 1, 0, 0); if (!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, code, u, uLen)) { ((Gfx8BitFont *)font)->getCharProc(code, &charProc); if ((resDict = ((Gfx8BitFont *)font)->getResources())) { pushResources(resDict); } if (charProc.isStream()) { display(&charProc, gFalse); } else { error(getPos(), "Missing or bad Type3 CharProc entry"); } out->endType3Char(state); if (resDict) { popResources(); } charProc.free(); } restoreState(); curX += tdx; curY += tdy; state->moveTo(curX, curY); state->textSetPos(lineX, lineY); p += n; len -= n; } parser = oldParser; } else if (out->useDrawChar()) { state->textTransformDelta(0, state->getRise(), &riseX, &riseY); p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx, &dy, &originX, &originY); if (wMode) { dx *= state->getFontSize(); dy = dy * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dy += state->getWordSpace(); } } else { dx = dx * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dx += state->getWordSpace(); } dx *= state->getHorizScaling(); dy *= state->getFontSize(); } state->textTransformDelta(dx, dy, &tdx, &tdy); originX *= state->getFontSize(); originY *= state->getFontSize(); state->textTransformDelta(originX, originY, &tOriginX, &tOriginY); if (!contentIsHidden()) { out->drawChar(state, state->getCurX() + riseX, state->getCurY() + riseY, tdx, tdy, tOriginX, tOriginY, code, n, u, uLen); } state->shift(tdx, tdy); p += n; len -= n; } } else { dx = dy = 0; p = s->getCString(); len = s->getLength(); nChars = nSpaces = 0; while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx2, &dy2, &originX, &originY); dx += dx2; dy += dy2; if (n == 1 && *p == ' ') { ++nSpaces; } ++nChars; p += n; len -= n; } if (wMode) { dx *= state->getFontSize(); dy = dy * state->getFontSize() + nChars * state->getCharSpace() + nSpaces * state->getWordSpace(); } else { dx = dx * state->getFontSize() + nChars * state->getCharSpace() + nSpaces * state->getWordSpace(); dx *= state->getHorizScaling(); dy *= state->getFontSize(); } state->textTransformDelta(dx, dy, &tdx, &tdy); if (!contentIsHidden()) out->drawString(state, s); state->shift(tdx, tdy); } if (out->useDrawChar()) { out->endString(state); } updateLevel += 10 * s->getLength(); }
DoS
0
void Gfx::doShowText(GooString *s) { GfxFont *font; int wMode; double riseX, riseY; CharCode code; Unicode *u = NULL; double x, y, dx, dy, dx2, dy2, curX, curY, tdx, tdy, lineX, lineY; double originX, originY, tOriginX, tOriginY; double oldCTM[6], newCTM[6]; double *mat; Object charProc; Dict *resDict; Parser *oldParser; char *p; int len, n, uLen, nChars, nSpaces, i; font = state->getFont(); wMode = font->getWMode(); if (out->useDrawChar()) { out->beginString(state, s); } if (font->getType() == fontType3 && out->interpretType3Chars()) { mat = state->getCTM(); for (i = 0; i < 6; ++i) { oldCTM[i] = mat[i]; } mat = state->getTextMat(); newCTM[0] = mat[0] * oldCTM[0] + mat[1] * oldCTM[2]; newCTM[1] = mat[0] * oldCTM[1] + mat[1] * oldCTM[3]; newCTM[2] = mat[2] * oldCTM[0] + mat[3] * oldCTM[2]; newCTM[3] = mat[2] * oldCTM[1] + mat[3] * oldCTM[3]; mat = font->getFontMatrix(); newCTM[0] = mat[0] * newCTM[0] + mat[1] * newCTM[2]; newCTM[1] = mat[0] * newCTM[1] + mat[1] * newCTM[3]; newCTM[2] = mat[2] * newCTM[0] + mat[3] * newCTM[2]; newCTM[3] = mat[2] * newCTM[1] + mat[3] * newCTM[3]; newCTM[0] *= state->getFontSize(); newCTM[1] *= state->getFontSize(); newCTM[2] *= state->getFontSize(); newCTM[3] *= state->getFontSize(); newCTM[0] *= state->getHorizScaling(); newCTM[2] *= state->getHorizScaling(); state->textTransformDelta(0, state->getRise(), &riseX, &riseY); curX = state->getCurX(); curY = state->getCurY(); lineX = state->getLineX(); lineY = state->getLineY(); oldParser = parser; p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx, &dy, &originX, &originY); dx = dx * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dx += state->getWordSpace(); } dx *= state->getHorizScaling(); dy *= state->getFontSize(); state->textTransformDelta(dx, dy, &tdx, &tdy); state->transform(curX + riseX, curY + riseY, &x, &y); saveState(); state->setCTM(newCTM[0], newCTM[1], newCTM[2], newCTM[3], x, y); out->updateCTM(state, 1, 0, 0, 1, 0, 0); if (!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, code, u, uLen)) { ((Gfx8BitFont *)font)->getCharProc(code, &charProc); if ((resDict = ((Gfx8BitFont *)font)->getResources())) { pushResources(resDict); } if (charProc.isStream()) { display(&charProc, gFalse); } else { error(getPos(), "Missing or bad Type3 CharProc entry"); } out->endType3Char(state); if (resDict) { popResources(); } charProc.free(); } restoreState(); curX += tdx; curY += tdy; state->moveTo(curX, curY); state->textSetPos(lineX, lineY); p += n; len -= n; } parser = oldParser; } else if (out->useDrawChar()) { state->textTransformDelta(0, state->getRise(), &riseX, &riseY); p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx, &dy, &originX, &originY); if (wMode) { dx *= state->getFontSize(); dy = dy * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dy += state->getWordSpace(); } } else { dx = dx * state->getFontSize() + state->getCharSpace(); if (n == 1 && *p == ' ') { dx += state->getWordSpace(); } dx *= state->getHorizScaling(); dy *= state->getFontSize(); } state->textTransformDelta(dx, dy, &tdx, &tdy); originX *= state->getFontSize(); originY *= state->getFontSize(); state->textTransformDelta(originX, originY, &tOriginX, &tOriginY); if (!contentIsHidden()) { out->drawChar(state, state->getCurX() + riseX, state->getCurY() + riseY, tdx, tdy, tOriginX, tOriginY, code, n, u, uLen); } state->shift(tdx, tdy); p += n; len -= n; } } else { dx = dy = 0; p = s->getCString(); len = s->getLength(); nChars = nSpaces = 0; while (len > 0) { n = font->getNextChar(p, len, &code, &u, &uLen, &dx2, &dy2, &originX, &originY); dx += dx2; dy += dy2; if (n == 1 && *p == ' ') { ++nSpaces; } ++nChars; p += n; len -= n; } if (wMode) { dx *= state->getFontSize(); dy = dy * state->getFontSize() + nChars * state->getCharSpace() + nSpaces * state->getWordSpace(); } else { dx = dx * state->getFontSize() + nChars * state->getCharSpace() + nSpaces * state->getWordSpace(); dx *= state->getHorizScaling(); dy *= state->getFontSize(); } state->textTransformDelta(dx, dy, &tdx, &tdy); if (!contentIsHidden()) out->drawString(state, s); state->shift(tdx, tdy); } if (out->useDrawChar()) { out->endString(state); } updateLevel += 10 * s->getLength(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,427
void Gfx::doSoftMask(Object *str, GBool alpha, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, Function *transferFunc, GfxColor *backdropColor) { Dict *dict, *resDict; double m[6], bbox[4]; Object obj1, obj2; int i; if (formDepth > 20) { return; } dict = str->streamGetDict(); dict->lookup("FormType", &obj1); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(getPos(), "Unknown form type"); } obj1.free(); dict->lookup("BBox", &obj1); if (!obj1.isArray()) { obj1.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { obj1.arrayGet(i, &obj2); bbox[i] = obj2.getNum(); obj2.free(); } obj1.free(); dict->lookup("Matrix", &obj1); if (obj1.isArray()) { for (i = 0; i < 6; ++i) { obj1.arrayGet(i, &obj2); m[i] = obj2.getNum(); obj2.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } obj1.free(); dict->lookup("Resources", &obj1); resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL; ++formDepth; doForm1(str, resDict, m, bbox, gTrue, gTrue, blendingColorSpace, isolated, knockout, alpha, transferFunc, backdropColor); --formDepth; if (blendingColorSpace) { delete blendingColorSpace; } obj1.free(); }
DoS
0
void Gfx::doSoftMask(Object *str, GBool alpha, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, Function *transferFunc, GfxColor *backdropColor) { Dict *dict, *resDict; double m[6], bbox[4]; Object obj1, obj2; int i; if (formDepth > 20) { return; } dict = str->streamGetDict(); dict->lookup("FormType", &obj1); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(getPos(), "Unknown form type"); } obj1.free(); dict->lookup("BBox", &obj1); if (!obj1.isArray()) { obj1.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { obj1.arrayGet(i, &obj2); bbox[i] = obj2.getNum(); obj2.free(); } obj1.free(); dict->lookup("Matrix", &obj1); if (obj1.isArray()) { for (i = 0; i < 6; ++i) { obj1.arrayGet(i, &obj2); m[i] = obj2.getNum(); obj2.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } obj1.free(); dict->lookup("Resources", &obj1); resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL; ++formDepth; doForm1(str, resDict, m, bbox, gTrue, gTrue, blendingColorSpace, isolated, knockout, alpha, transferFunc, backdropColor); --formDepth; if (blendingColorSpace) { delete blendingColorSpace; } obj1.free(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,428
void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, GBool stroke, GBool eoFill) { GfxPatternColorSpace *patCS; GfxColorSpace *cs; GfxColor color; GfxPath *savedPath; double xMin, yMin, xMax, yMax, x, y, x1, y1; double cxMin, cyMin, cxMax, cyMax; int xi0, yi0, xi1, yi1, xi, yi; double *ctm, *btm, *ptm; double m[6], ictm[6], m1[6], imb[6]; double det; double xstep, ystep; int i; patCS = (GfxPatternColorSpace *)(stroke ? state->getStrokeColorSpace() : state->getFillColorSpace()); ctm = state->getCTM(); btm = baseMatrix; ptm = tPat->getMatrix(); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det; ictm[3] = ctm[0] * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det; m1[0] = ptm[0] * btm[0] + ptm[1] * btm[2]; m1[1] = ptm[0] * btm[1] + ptm[1] * btm[3]; m1[2] = ptm[2] * btm[0] + ptm[3] * btm[2]; m1[3] = ptm[2] * btm[1] + ptm[3] * btm[3]; m1[4] = ptm[4] * btm[0] + ptm[5] * btm[2] + btm[4]; m1[5] = ptm[4] * btm[1] + ptm[5] * btm[3] + btm[5]; m[0] = m1[0] * ictm[0] + m1[1] * ictm[2]; m[1] = m1[0] * ictm[1] + m1[1] * ictm[3]; m[2] = m1[2] * ictm[0] + m1[3] * ictm[2]; m[3] = m1[2] * ictm[1] + m1[3] * ictm[3]; m[4] = m1[4] * ictm[0] + m1[5] * ictm[2] + ictm[4]; m[5] = m1[4] * ictm[1] + m1[5] * ictm[3] + ictm[5]; det = 1 / (m1[0] * m1[3] - m1[1] * m1[2]); imb[0] = m1[3] * det; imb[1] = -m1[1] * det; imb[2] = -m1[2] * det; imb[3] = m1[0] * det; imb[4] = (m1[2] * m1[5] - m1[3] * m1[4]) * det; imb[5] = (m1[1] * m1[4] - m1[0] * m1[5]) * det; savedPath = state->getPath()->copy(); saveState(); if (tPat->getPaintType() == 2 && (cs = patCS->getUnder())) { state->setFillColorSpace(cs->copy()); out->updateFillColorSpace(state); state->setStrokeColorSpace(cs->copy()); out->updateStrokeColorSpace(state); if (stroke) { state->setFillColor(state->getStrokeColor()); } else { state->setStrokeColor(state->getFillColor()); } } else { cs = new GfxDeviceGrayColorSpace(); state->setFillColorSpace(cs); cs->getDefaultColor(&color); state->setFillColor(&color); out->updateFillColorSpace(state); state->setStrokeColorSpace(new GfxDeviceGrayColorSpace()); state->setStrokeColor(&color); out->updateStrokeColorSpace(state); } state->setFillPattern(NULL); out->updateFillColor(state); state->setStrokePattern(NULL); out->updateStrokeColor(state); if (stroke) { state->clipToStrokePath(); out->clipToStrokePath(state); } else if (!textHaveCSPattern && !maskHaveCSPattern) { state->clip(); if (eoFill) { out->eoClip(state); } else { out->clip(state); } } state->clearPath(); state->setLineWidth(0); out->updateLineWidth(state); state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax); if (cxMin > cxMax || cyMin > cyMax) { goto restore; } xMin = xMax = cxMin * imb[0] + cyMin * imb[2] + imb[4]; yMin = yMax = cxMin * imb[1] + cyMin * imb[3] + imb[5]; x1 = cxMin * imb[0] + cyMax * imb[2] + imb[4]; y1 = cxMin * imb[1] + cyMax * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } x1 = cxMax * imb[0] + cyMin * imb[2] + imb[4]; y1 = cxMax * imb[1] + cyMin * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } x1 = cxMax * imb[0] + cyMax * imb[2] + imb[4]; y1 = cxMax * imb[1] + cyMax * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } xstep = fabs(tPat->getXStep()); ystep = fabs(tPat->getYStep()); xi0 = (int)ceil((xMin - tPat->getBBox()[2]) / xstep); xi1 = (int)floor((xMax - tPat->getBBox()[0]) / xstep) + 1; yi0 = (int)ceil((yMin - tPat->getBBox()[3]) / ystep); yi1 = (int)floor((yMax - tPat->getBBox()[1]) / ystep) + 1; for (i = 0; i < 4; ++i) { m1[i] = m[i]; } if (!contentIsHidden()) { m1[4] = m[4]; m1[5] = m[5]; if (out->useTilingPatternFill() && out->tilingPatternFill(state, tPat->getContentStream(), tPat->getPaintType(), tPat->getResDict(), m1, tPat->getBBox(), xi0, yi0, xi1, yi1, xstep, ystep)) { goto restore; } else { for (yi = yi0; yi < yi1; ++yi) { for (xi = xi0; xi < xi1; ++xi) { x = xi * xstep; y = yi * ystep; m1[4] = x * m[0] + y * m[2] + m[4]; m1[5] = x * m[1] + y * m[3] + m[5]; doForm1(tPat->getContentStream(), tPat->getResDict(), m1, tPat->getBBox()); } } } } restore: restoreState(); state->setPath(savedPath); }
DoS
0
void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, GBool stroke, GBool eoFill) { GfxPatternColorSpace *patCS; GfxColorSpace *cs; GfxColor color; GfxPath *savedPath; double xMin, yMin, xMax, yMax, x, y, x1, y1; double cxMin, cyMin, cxMax, cyMax; int xi0, yi0, xi1, yi1, xi, yi; double *ctm, *btm, *ptm; double m[6], ictm[6], m1[6], imb[6]; double det; double xstep, ystep; int i; patCS = (GfxPatternColorSpace *)(stroke ? state->getStrokeColorSpace() : state->getFillColorSpace()); ctm = state->getCTM(); btm = baseMatrix; ptm = tPat->getMatrix(); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det; ictm[3] = ctm[0] * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det; m1[0] = ptm[0] * btm[0] + ptm[1] * btm[2]; m1[1] = ptm[0] * btm[1] + ptm[1] * btm[3]; m1[2] = ptm[2] * btm[0] + ptm[3] * btm[2]; m1[3] = ptm[2] * btm[1] + ptm[3] * btm[3]; m1[4] = ptm[4] * btm[0] + ptm[5] * btm[2] + btm[4]; m1[5] = ptm[4] * btm[1] + ptm[5] * btm[3] + btm[5]; m[0] = m1[0] * ictm[0] + m1[1] * ictm[2]; m[1] = m1[0] * ictm[1] + m1[1] * ictm[3]; m[2] = m1[2] * ictm[0] + m1[3] * ictm[2]; m[3] = m1[2] * ictm[1] + m1[3] * ictm[3]; m[4] = m1[4] * ictm[0] + m1[5] * ictm[2] + ictm[4]; m[5] = m1[4] * ictm[1] + m1[5] * ictm[3] + ictm[5]; det = 1 / (m1[0] * m1[3] - m1[1] * m1[2]); imb[0] = m1[3] * det; imb[1] = -m1[1] * det; imb[2] = -m1[2] * det; imb[3] = m1[0] * det; imb[4] = (m1[2] * m1[5] - m1[3] * m1[4]) * det; imb[5] = (m1[1] * m1[4] - m1[0] * m1[5]) * det; savedPath = state->getPath()->copy(); saveState(); if (tPat->getPaintType() == 2 && (cs = patCS->getUnder())) { state->setFillColorSpace(cs->copy()); out->updateFillColorSpace(state); state->setStrokeColorSpace(cs->copy()); out->updateStrokeColorSpace(state); if (stroke) { state->setFillColor(state->getStrokeColor()); } else { state->setStrokeColor(state->getFillColor()); } } else { cs = new GfxDeviceGrayColorSpace(); state->setFillColorSpace(cs); cs->getDefaultColor(&color); state->setFillColor(&color); out->updateFillColorSpace(state); state->setStrokeColorSpace(new GfxDeviceGrayColorSpace()); state->setStrokeColor(&color); out->updateStrokeColorSpace(state); } state->setFillPattern(NULL); out->updateFillColor(state); state->setStrokePattern(NULL); out->updateStrokeColor(state); if (stroke) { state->clipToStrokePath(); out->clipToStrokePath(state); } else if (!textHaveCSPattern && !maskHaveCSPattern) { state->clip(); if (eoFill) { out->eoClip(state); } else { out->clip(state); } } state->clearPath(); state->setLineWidth(0); out->updateLineWidth(state); state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax); if (cxMin > cxMax || cyMin > cyMax) { goto restore; } xMin = xMax = cxMin * imb[0] + cyMin * imb[2] + imb[4]; yMin = yMax = cxMin * imb[1] + cyMin * imb[3] + imb[5]; x1 = cxMin * imb[0] + cyMax * imb[2] + imb[4]; y1 = cxMin * imb[1] + cyMax * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } x1 = cxMax * imb[0] + cyMin * imb[2] + imb[4]; y1 = cxMax * imb[1] + cyMin * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } x1 = cxMax * imb[0] + cyMax * imb[2] + imb[4]; y1 = cxMax * imb[1] + cyMax * imb[3] + imb[5]; if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } xstep = fabs(tPat->getXStep()); ystep = fabs(tPat->getYStep()); xi0 = (int)ceil((xMin - tPat->getBBox()[2]) / xstep); xi1 = (int)floor((xMax - tPat->getBBox()[0]) / xstep) + 1; yi0 = (int)ceil((yMin - tPat->getBBox()[3]) / ystep); yi1 = (int)floor((yMax - tPat->getBBox()[1]) / ystep) + 1; for (i = 0; i < 4; ++i) { m1[i] = m[i]; } if (!contentIsHidden()) { m1[4] = m[4]; m1[5] = m[5]; if (out->useTilingPatternFill() && out->tilingPatternFill(state, tPat->getContentStream(), tPat->getPaintType(), tPat->getResDict(), m1, tPat->getBBox(), xi0, yi0, xi1, yi1, xstep, ystep)) { goto restore; } else { for (yi = yi0; yi < yi1; ++yi) { for (xi = xi0; xi < xi1; ++xi) { x = xi * xstep; y = yi * ystep; m1[4] = x * m[0] + y * m[2] + m[4]; m1[5] = x * m[1] + y * m[3] + m[5]; doForm1(tPat->getContentStream(), tPat->getResDict(), m1, tPat->getBBox()); } } } } restore: restoreState(); state->setPath(savedPath); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,429
void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, double xMin, double yMin, double xMax, double yMax) { Dict *dict, *resDict; Object matrixObj, bboxObj, resObj; Object obj1; double m[6], bbox[4], ictm[6]; double *ctm; double formX0, formY0, formX1, formY1; double annotX0, annotY0, annotX1, annotY1; double det, x, y, sx, sy; double r, g, b; GfxColor color; double *dash, *dash2; int dashLength; int i; ctm = state->getCTM(); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det; ictm[3] = ctm[0] * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det; x = baseMatrix[0] * xMin + baseMatrix[2] * yMin + baseMatrix[4]; y = baseMatrix[1] * xMin + baseMatrix[3] * yMin + baseMatrix[5]; annotX0 = ictm[0] * x + ictm[2] * y + ictm[4]; annotY0 = ictm[1] * x + ictm[3] * y + ictm[5]; x = baseMatrix[0] * xMax + baseMatrix[2] * yMax + baseMatrix[4]; y = baseMatrix[1] * xMax + baseMatrix[3] * yMax + baseMatrix[5]; annotX1 = ictm[0] * x + ictm[2] * y + ictm[4]; annotY1 = ictm[1] * x + ictm[3] * y + ictm[5]; if (annotX0 > annotX1) { x = annotX0; annotX0 = annotX1; annotX1 = x; } if (annotY0 > annotY1) { y = annotY0; annotY0 = annotY1; annotY1 = y; } if (str->isStream()) { dict = str->streamGetDict(); dict->lookup("BBox", &bboxObj); if (!bboxObj.isArray()) { bboxObj.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { bboxObj.arrayGet(i, &obj1); bbox[i] = obj1.getNum(); obj1.free(); } bboxObj.free(); dict->lookup("Matrix", &matrixObj); if (matrixObj.isArray() && matrixObj.arrayGetLength() >= 6) { for (i = 0; i < 6; ++i) { matrixObj.arrayGet(i, &obj1); m[i] = obj1.getNum(); obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } matrixObj.free(); formX0 = bbox[0] * m[0] + bbox[1] * m[2] + m[4]; formY0 = bbox[0] * m[1] + bbox[1] * m[3] + m[5]; formX1 = bbox[2] * m[0] + bbox[3] * m[2] + m[4]; formY1 = bbox[2] * m[1] + bbox[3] * m[3] + m[5]; if (formX0 > formX1) { x = formX0; formX0 = formX1; formX1 = x; } if (formY0 > formY1) { y = formY0; formY0 = formY1; formY1 = y; } if (formX1 == formX0) { sx = 1; } else { sx = (annotX1 - annotX0) / (formX1 - formX0); } if (formY1 == formY0) { sy = 1; } else { sy = (annotY1 - annotY0) / (formY1 - formY0); } m[0] *= sx; m[2] *= sx; m[4] = (m[4] - formX0) * sx + annotX0; m[1] *= sy; m[3] *= sy; m[5] = (m[5] - formY0) * sy + annotY0; dict->lookup("Resources", &resObj); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; doForm1(str, resDict, m, bbox); resObj.free(); } if (border && border->getWidth() > 0) { if (state->getStrokeColorSpace()->getMode() != csDeviceRGB) { state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceRGBColorSpace()); out->updateStrokeColorSpace(state); } if (aColor && (aColor->getSpace() == AnnotColor::colorRGB)) { const double *values = aColor->getValues(); r = values[0]; g = values[1]; b = values[2]; } else { r = g = b = 0; }; color.c[0] = dblToCol(r); color.c[1] = dblToCol(g); color.c[2] = dblToCol(b); state->setStrokeColor(&color); out->updateStrokeColor(state); x = (baseMatrix[0] + baseMatrix[2]) * ictm[0] + (baseMatrix[1] + baseMatrix[3]) * ictm[2]; y = (baseMatrix[0] + baseMatrix[2]) * ictm[1] + (baseMatrix[1] + baseMatrix[3]) * ictm[3]; x = sqrt(0.5 * (x * x + y * y)); state->setLineWidth(x * border->getWidth()); out->updateLineWidth(state); dashLength = border->getDashLength(); dash = border->getDash(); if (border->getStyle() == AnnotBorder::borderDashed && dashLength > 0) { dash2 = (double *)gmallocn(dashLength, sizeof(double)); for (i = 0; i < dashLength; ++i) { dash2[i] = x * dash[i]; } state->setLineDash(dash2, dashLength, 0); out->updateLineDash(state); } state->clearPath(); state->moveTo(annotX0, out->upsideDown() ? annotY0 : annotY1); state->lineTo(annotX1, out->upsideDown() ? annotY0 : annotY1); if (border->getStyle() != AnnotBorder::borderUnderlined) { state->lineTo(annotX1, out->upsideDown() ? annotY1 : annotY0); state->lineTo(annotX0, out->upsideDown() ? annotY1 : annotY0); state->closePath(); } out->stroke(state); } }
DoS
0
void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, double xMin, double yMin, double xMax, double yMax) { Dict *dict, *resDict; Object matrixObj, bboxObj, resObj; Object obj1; double m[6], bbox[4], ictm[6]; double *ctm; double formX0, formY0, formX1, formY1; double annotX0, annotY0, annotX1, annotY1; double det, x, y, sx, sy; double r, g, b; GfxColor color; double *dash, *dash2; int dashLength; int i; ctm = state->getCTM(); det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det; ictm[3] = ctm[0] * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det; x = baseMatrix[0] * xMin + baseMatrix[2] * yMin + baseMatrix[4]; y = baseMatrix[1] * xMin + baseMatrix[3] * yMin + baseMatrix[5]; annotX0 = ictm[0] * x + ictm[2] * y + ictm[4]; annotY0 = ictm[1] * x + ictm[3] * y + ictm[5]; x = baseMatrix[0] * xMax + baseMatrix[2] * yMax + baseMatrix[4]; y = baseMatrix[1] * xMax + baseMatrix[3] * yMax + baseMatrix[5]; annotX1 = ictm[0] * x + ictm[2] * y + ictm[4]; annotY1 = ictm[1] * x + ictm[3] * y + ictm[5]; if (annotX0 > annotX1) { x = annotX0; annotX0 = annotX1; annotX1 = x; } if (annotY0 > annotY1) { y = annotY0; annotY0 = annotY1; annotY1 = y; } if (str->isStream()) { dict = str->streamGetDict(); dict->lookup("BBox", &bboxObj); if (!bboxObj.isArray()) { bboxObj.free(); error(getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { bboxObj.arrayGet(i, &obj1); bbox[i] = obj1.getNum(); obj1.free(); } bboxObj.free(); dict->lookup("Matrix", &matrixObj); if (matrixObj.isArray() && matrixObj.arrayGetLength() >= 6) { for (i = 0; i < 6; ++i) { matrixObj.arrayGet(i, &obj1); m[i] = obj1.getNum(); obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } matrixObj.free(); formX0 = bbox[0] * m[0] + bbox[1] * m[2] + m[4]; formY0 = bbox[0] * m[1] + bbox[1] * m[3] + m[5]; formX1 = bbox[2] * m[0] + bbox[3] * m[2] + m[4]; formY1 = bbox[2] * m[1] + bbox[3] * m[3] + m[5]; if (formX0 > formX1) { x = formX0; formX0 = formX1; formX1 = x; } if (formY0 > formY1) { y = formY0; formY0 = formY1; formY1 = y; } if (formX1 == formX0) { sx = 1; } else { sx = (annotX1 - annotX0) / (formX1 - formX0); } if (formY1 == formY0) { sy = 1; } else { sy = (annotY1 - annotY0) / (formY1 - formY0); } m[0] *= sx; m[2] *= sx; m[4] = (m[4] - formX0) * sx + annotX0; m[1] *= sy; m[3] *= sy; m[5] = (m[5] - formY0) * sy + annotY0; dict->lookup("Resources", &resObj); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; doForm1(str, resDict, m, bbox); resObj.free(); } if (border && border->getWidth() > 0) { if (state->getStrokeColorSpace()->getMode() != csDeviceRGB) { state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceRGBColorSpace()); out->updateStrokeColorSpace(state); } if (aColor && (aColor->getSpace() == AnnotColor::colorRGB)) { const double *values = aColor->getValues(); r = values[0]; g = values[1]; b = values[2]; } else { r = g = b = 0; }; color.c[0] = dblToCol(r); color.c[1] = dblToCol(g); color.c[2] = dblToCol(b); state->setStrokeColor(&color); out->updateStrokeColor(state); x = (baseMatrix[0] + baseMatrix[2]) * ictm[0] + (baseMatrix[1] + baseMatrix[3]) * ictm[2]; y = (baseMatrix[0] + baseMatrix[2]) * ictm[1] + (baseMatrix[1] + baseMatrix[3]) * ictm[3]; x = sqrt(0.5 * (x * x + y * y)); state->setLineWidth(x * border->getWidth()); out->updateLineWidth(state); dashLength = border->getDashLength(); dash = border->getDash(); if (border->getStyle() == AnnotBorder::borderDashed && dashLength > 0) { dash2 = (double *)gmallocn(dashLength, sizeof(double)); for (i = 0; i < dashLength; ++i) { dash2[i] = x * dash[i]; } state->setLineDash(dash2, dashLength, 0); out->updateLineDash(state); } state->clearPath(); state->moveTo(annotX0, out->upsideDown() ? annotY0 : annotY1); state->lineTo(annotX1, out->upsideDown() ? annotY0 : annotY1); if (border->getStyle() != AnnotBorder::borderUnderlined) { state->lineTo(annotX1, out->upsideDown() ? annotY1 : annotY0); state->lineTo(annotX0, out->upsideDown() ? annotY1 : annotY0); state->closePath(); } out->stroke(state); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,430
void Gfx::execOp(Object *cmd, Object args[], int numArgs) { Operator *op; char *name; Object *argPtr; int i; name = cmd->getCmd(); if (!(op = findOp(name))) { if (ignoreUndef == 0) error(getPos(), "Unknown operator '%s'", name); return; } argPtr = args; if (op->numArgs >= 0) { if (numArgs < op->numArgs) { error(getPos(), "Too few (%d) args to '%s' operator", numArgs, name); commandAborted = gTrue; return; } if (numArgs > op->numArgs) { #if 0 error(getPos(), "Too many (%d) args to '%s' operator", numArgs, name); #endif argPtr += numArgs - op->numArgs; numArgs = op->numArgs; } } else { if (numArgs > -op->numArgs) { error(getPos(), "Too many (%d) args to '%s' operator", numArgs, name); return; } } for (i = 0; i < numArgs; ++i) { if (!checkArg(&argPtr[i], op->tchk[i])) { error(getPos(), "Arg #%d to '%s' operator is wrong type (%s)", i, name, argPtr[i].getTypeName()); return; } } (this->*op->func)(argPtr, numArgs); }
DoS
0
void Gfx::execOp(Object *cmd, Object args[], int numArgs) { Operator *op; char *name; Object *argPtr; int i; name = cmd->getCmd(); if (!(op = findOp(name))) { if (ignoreUndef == 0) error(getPos(), "Unknown operator '%s'", name); return; } argPtr = args; if (op->numArgs >= 0) { if (numArgs < op->numArgs) { error(getPos(), "Too few (%d) args to '%s' operator", numArgs, name); commandAborted = gTrue; return; } if (numArgs > op->numArgs) { #if 0 error(getPos(), "Too many (%d) args to '%s' operator", numArgs, name); #endif argPtr += numArgs - op->numArgs; numArgs = op->numArgs; } } else { if (numArgs > -op->numArgs) { error(getPos(), "Too many (%d) args to '%s' operator", numArgs, name); return; } } for (i = 0; i < numArgs; ++i) { if (!checkArg(&argPtr[i], op->tchk[i])) { error(getPos(), "Arg #%d to '%s' operator is wrong type (%s)", i, name, argPtr[i].getTypeName()); return; } } (this->*op->func)(argPtr, numArgs); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,431
void Gfx::fillPatch(GfxPatch *patch, int nComps, int depth) { GfxPatch patch00, patch01, patch10, patch11; double xx[4][8], yy[4][8]; double xxm, yym; int i; for (i = 0; i < nComps; ++i) { if (abs(patch->color[0][0].c[i] - patch->color[0][1].c[i]) > patchColorDelta || abs(patch->color[0][1].c[i] - patch->color[1][1].c[i]) > patchColorDelta || abs(patch->color[1][1].c[i] - patch->color[1][0].c[i]) > patchColorDelta || abs(patch->color[1][0].c[i] - patch->color[0][0].c[i]) > patchColorDelta) { break; } } if (i == nComps || depth == patchMaxDepth) { state->setFillColor(&patch->color[0][0]); out->updateFillColor(state); state->moveTo(patch->x[0][0], patch->y[0][0]); state->curveTo(patch->x[0][1], patch->y[0][1], patch->x[0][2], patch->y[0][2], patch->x[0][3], patch->y[0][3]); state->curveTo(patch->x[1][3], patch->y[1][3], patch->x[2][3], patch->y[2][3], patch->x[3][3], patch->y[3][3]); state->curveTo(patch->x[3][2], patch->y[3][2], patch->x[3][1], patch->y[3][1], patch->x[3][0], patch->y[3][0]); state->curveTo(patch->x[2][0], patch->y[2][0], patch->x[1][0], patch->y[1][0], patch->x[0][0], patch->y[0][0]); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } else { for (i = 0; i < 4; ++i) { xx[i][0] = patch->x[i][0]; yy[i][0] = patch->y[i][0]; xx[i][1] = 0.5 * (patch->x[i][0] + patch->x[i][1]); yy[i][1] = 0.5 * (patch->y[i][0] + patch->y[i][1]); xxm = 0.5 * (patch->x[i][1] + patch->x[i][2]); yym = 0.5 * (patch->y[i][1] + patch->y[i][2]); xx[i][6] = 0.5 * (patch->x[i][2] + patch->x[i][3]); yy[i][6] = 0.5 * (patch->y[i][2] + patch->y[i][3]); xx[i][2] = 0.5 * (xx[i][1] + xxm); yy[i][2] = 0.5 * (yy[i][1] + yym); xx[i][5] = 0.5 * (xxm + xx[i][6]); yy[i][5] = 0.5 * (yym + yy[i][6]); xx[i][3] = xx[i][4] = 0.5 * (xx[i][2] + xx[i][5]); yy[i][3] = yy[i][4] = 0.5 * (yy[i][2] + yy[i][5]); xx[i][7] = patch->x[i][3]; yy[i][7] = patch->y[i][3]; } for (i = 0; i < 4; ++i) { patch00.x[0][i] = xx[0][i]; patch00.y[0][i] = yy[0][i]; patch00.x[1][i] = 0.5 * (xx[0][i] + xx[1][i]); patch00.y[1][i] = 0.5 * (yy[0][i] + yy[1][i]); xxm = 0.5 * (xx[1][i] + xx[2][i]); yym = 0.5 * (yy[1][i] + yy[2][i]); patch10.x[2][i] = 0.5 * (xx[2][i] + xx[3][i]); patch10.y[2][i] = 0.5 * (yy[2][i] + yy[3][i]); patch00.x[2][i] = 0.5 * (patch00.x[1][i] + xxm); patch00.y[2][i] = 0.5 * (patch00.y[1][i] + yym); patch10.x[1][i] = 0.5 * (xxm + patch10.x[2][i]); patch10.y[1][i] = 0.5 * (yym + patch10.y[2][i]); patch00.x[3][i] = 0.5 * (patch00.x[2][i] + patch10.x[1][i]); patch00.y[3][i] = 0.5 * (patch00.y[2][i] + patch10.y[1][i]); patch10.x[0][i] = patch00.x[3][i]; patch10.y[0][i] = patch00.y[3][i]; patch10.x[3][i] = xx[3][i]; patch10.y[3][i] = yy[3][i]; } for (i = 4; i < 8; ++i) { patch01.x[0][i-4] = xx[0][i]; patch01.y[0][i-4] = yy[0][i]; patch01.x[1][i-4] = 0.5 * (xx[0][i] + xx[1][i]); patch01.y[1][i-4] = 0.5 * (yy[0][i] + yy[1][i]); xxm = 0.5 * (xx[1][i] + xx[2][i]); yym = 0.5 * (yy[1][i] + yy[2][i]); patch11.x[2][i-4] = 0.5 * (xx[2][i] + xx[3][i]); patch11.y[2][i-4] = 0.5 * (yy[2][i] + yy[3][i]); patch01.x[2][i-4] = 0.5 * (patch01.x[1][i-4] + xxm); patch01.y[2][i-4] = 0.5 * (patch01.y[1][i-4] + yym); patch11.x[1][i-4] = 0.5 * (xxm + patch11.x[2][i-4]); patch11.y[1][i-4] = 0.5 * (yym + patch11.y[2][i-4]); patch01.x[3][i-4] = 0.5 * (patch01.x[2][i-4] + patch11.x[1][i-4]); patch01.y[3][i-4] = 0.5 * (patch01.y[2][i-4] + patch11.y[1][i-4]); patch11.x[0][i-4] = patch01.x[3][i-4]; patch11.y[0][i-4] = patch01.y[3][i-4]; patch11.x[3][i-4] = xx[3][i]; patch11.y[3][i-4] = yy[3][i]; } for (i = 0; i < nComps; ++i) { patch00.color[0][0].c[i] = patch->color[0][0].c[i]; patch00.color[0][1].c[i] = (patch->color[0][0].c[i] + patch->color[0][1].c[i]) / 2; patch01.color[0][0].c[i] = patch00.color[0][1].c[i]; patch01.color[0][1].c[i] = patch->color[0][1].c[i]; patch01.color[1][1].c[i] = (patch->color[0][1].c[i] + patch->color[1][1].c[i]) / 2; patch11.color[0][1].c[i] = patch01.color[1][1].c[i]; patch11.color[1][1].c[i] = patch->color[1][1].c[i]; patch11.color[1][0].c[i] = (patch->color[1][1].c[i] + patch->color[1][0].c[i]) / 2; patch10.color[1][1].c[i] = patch11.color[1][0].c[i]; patch10.color[1][0].c[i] = patch->color[1][0].c[i]; patch10.color[0][0].c[i] = (patch->color[1][0].c[i] + patch->color[0][0].c[i]) / 2; patch00.color[1][0].c[i] = patch10.color[0][0].c[i]; patch00.color[1][1].c[i] = (patch00.color[1][0].c[i] + patch01.color[1][1].c[i]) / 2; patch01.color[1][0].c[i] = patch00.color[1][1].c[i]; patch11.color[0][0].c[i] = patch00.color[1][1].c[i]; patch10.color[0][1].c[i] = patch00.color[1][1].c[i]; } fillPatch(&patch00, nComps, depth + 1); fillPatch(&patch10, nComps, depth + 1); fillPatch(&patch01, nComps, depth + 1); fillPatch(&patch11, nComps, depth + 1); } }
DoS
0
void Gfx::fillPatch(GfxPatch *patch, int nComps, int depth) { GfxPatch patch00, patch01, patch10, patch11; double xx[4][8], yy[4][8]; double xxm, yym; int i; for (i = 0; i < nComps; ++i) { if (abs(patch->color[0][0].c[i] - patch->color[0][1].c[i]) > patchColorDelta || abs(patch->color[0][1].c[i] - patch->color[1][1].c[i]) > patchColorDelta || abs(patch->color[1][1].c[i] - patch->color[1][0].c[i]) > patchColorDelta || abs(patch->color[1][0].c[i] - patch->color[0][0].c[i]) > patchColorDelta) { break; } } if (i == nComps || depth == patchMaxDepth) { state->setFillColor(&patch->color[0][0]); out->updateFillColor(state); state->moveTo(patch->x[0][0], patch->y[0][0]); state->curveTo(patch->x[0][1], patch->y[0][1], patch->x[0][2], patch->y[0][2], patch->x[0][3], patch->y[0][3]); state->curveTo(patch->x[1][3], patch->y[1][3], patch->x[2][3], patch->y[2][3], patch->x[3][3], patch->y[3][3]); state->curveTo(patch->x[3][2], patch->y[3][2], patch->x[3][1], patch->y[3][1], patch->x[3][0], patch->y[3][0]); state->curveTo(patch->x[2][0], patch->y[2][0], patch->x[1][0], patch->y[1][0], patch->x[0][0], patch->y[0][0]); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } else { for (i = 0; i < 4; ++i) { xx[i][0] = patch->x[i][0]; yy[i][0] = patch->y[i][0]; xx[i][1] = 0.5 * (patch->x[i][0] + patch->x[i][1]); yy[i][1] = 0.5 * (patch->y[i][0] + patch->y[i][1]); xxm = 0.5 * (patch->x[i][1] + patch->x[i][2]); yym = 0.5 * (patch->y[i][1] + patch->y[i][2]); xx[i][6] = 0.5 * (patch->x[i][2] + patch->x[i][3]); yy[i][6] = 0.5 * (patch->y[i][2] + patch->y[i][3]); xx[i][2] = 0.5 * (xx[i][1] + xxm); yy[i][2] = 0.5 * (yy[i][1] + yym); xx[i][5] = 0.5 * (xxm + xx[i][6]); yy[i][5] = 0.5 * (yym + yy[i][6]); xx[i][3] = xx[i][4] = 0.5 * (xx[i][2] + xx[i][5]); yy[i][3] = yy[i][4] = 0.5 * (yy[i][2] + yy[i][5]); xx[i][7] = patch->x[i][3]; yy[i][7] = patch->y[i][3]; } for (i = 0; i < 4; ++i) { patch00.x[0][i] = xx[0][i]; patch00.y[0][i] = yy[0][i]; patch00.x[1][i] = 0.5 * (xx[0][i] + xx[1][i]); patch00.y[1][i] = 0.5 * (yy[0][i] + yy[1][i]); xxm = 0.5 * (xx[1][i] + xx[2][i]); yym = 0.5 * (yy[1][i] + yy[2][i]); patch10.x[2][i] = 0.5 * (xx[2][i] + xx[3][i]); patch10.y[2][i] = 0.5 * (yy[2][i] + yy[3][i]); patch00.x[2][i] = 0.5 * (patch00.x[1][i] + xxm); patch00.y[2][i] = 0.5 * (patch00.y[1][i] + yym); patch10.x[1][i] = 0.5 * (xxm + patch10.x[2][i]); patch10.y[1][i] = 0.5 * (yym + patch10.y[2][i]); patch00.x[3][i] = 0.5 * (patch00.x[2][i] + patch10.x[1][i]); patch00.y[3][i] = 0.5 * (patch00.y[2][i] + patch10.y[1][i]); patch10.x[0][i] = patch00.x[3][i]; patch10.y[0][i] = patch00.y[3][i]; patch10.x[3][i] = xx[3][i]; patch10.y[3][i] = yy[3][i]; } for (i = 4; i < 8; ++i) { patch01.x[0][i-4] = xx[0][i]; patch01.y[0][i-4] = yy[0][i]; patch01.x[1][i-4] = 0.5 * (xx[0][i] + xx[1][i]); patch01.y[1][i-4] = 0.5 * (yy[0][i] + yy[1][i]); xxm = 0.5 * (xx[1][i] + xx[2][i]); yym = 0.5 * (yy[1][i] + yy[2][i]); patch11.x[2][i-4] = 0.5 * (xx[2][i] + xx[3][i]); patch11.y[2][i-4] = 0.5 * (yy[2][i] + yy[3][i]); patch01.x[2][i-4] = 0.5 * (patch01.x[1][i-4] + xxm); patch01.y[2][i-4] = 0.5 * (patch01.y[1][i-4] + yym); patch11.x[1][i-4] = 0.5 * (xxm + patch11.x[2][i-4]); patch11.y[1][i-4] = 0.5 * (yym + patch11.y[2][i-4]); patch01.x[3][i-4] = 0.5 * (patch01.x[2][i-4] + patch11.x[1][i-4]); patch01.y[3][i-4] = 0.5 * (patch01.y[2][i-4] + patch11.y[1][i-4]); patch11.x[0][i-4] = patch01.x[3][i-4]; patch11.y[0][i-4] = patch01.y[3][i-4]; patch11.x[3][i-4] = xx[3][i]; patch11.y[3][i-4] = yy[3][i]; } for (i = 0; i < nComps; ++i) { patch00.color[0][0].c[i] = patch->color[0][0].c[i]; patch00.color[0][1].c[i] = (patch->color[0][0].c[i] + patch->color[0][1].c[i]) / 2; patch01.color[0][0].c[i] = patch00.color[0][1].c[i]; patch01.color[0][1].c[i] = patch->color[0][1].c[i]; patch01.color[1][1].c[i] = (patch->color[0][1].c[i] + patch->color[1][1].c[i]) / 2; patch11.color[0][1].c[i] = patch01.color[1][1].c[i]; patch11.color[1][1].c[i] = patch->color[1][1].c[i]; patch11.color[1][0].c[i] = (patch->color[1][1].c[i] + patch->color[1][0].c[i]) / 2; patch10.color[1][1].c[i] = patch11.color[1][0].c[i]; patch10.color[1][0].c[i] = patch->color[1][0].c[i]; patch10.color[0][0].c[i] = (patch->color[1][0].c[i] + patch->color[0][0].c[i]) / 2; patch00.color[1][0].c[i] = patch10.color[0][0].c[i]; patch00.color[1][1].c[i] = (patch00.color[1][0].c[i] + patch01.color[1][1].c[i]) / 2; patch01.color[1][0].c[i] = patch00.color[1][1].c[i]; patch11.color[0][0].c[i] = patch00.color[1][1].c[i]; patch10.color[0][1].c[i] = patch00.color[1][1].c[i]; } fillPatch(&patch00, nComps, depth + 1); fillPatch(&patch10, nComps, depth + 1); fillPatch(&patch01, nComps, depth + 1); fillPatch(&patch11, nComps, depth + 1); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,432
Operator *Gfx::findOp(char *name) { int a, b, m, cmp; a = -1; b = numOps; while (b - a > 1) { m = (a + b) / 2; cmp = strcmp(opTab[m].name, name); if (cmp < 0) a = m; else if (cmp > 0) b = m; else a = b = m; } if (cmp != 0) return NULL; return &opTab[a]; }
DoS
0
Operator *Gfx::findOp(char *name) { int a, b, m, cmp; a = -1; b = numOps; while (b - a > 1) { m = (a + b) / 2; cmp = strcmp(opTab[m].name, name); if (cmp < 0) a = m; else if (cmp > 0) b = m; else a = b = m; } if (cmp != 0) return NULL; return &opTab[a]; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,433
PopplerCache *Gfx::getIccColorSpaceCache() { return &iccColorSpaceCache; }
DoS
0
PopplerCache *Gfx::getIccColorSpaceCache() { return &iccColorSpaceCache; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,434
int Gfx::getPos() { return parser ? parser->getPos() : -1; }
DoS
0
int Gfx::getPos() { return parser ? parser->getPos() : -1; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,435
void Gfx::go(GBool topLevel) { Object obj; Object args[maxArgs]; int numArgs, i; int lastAbortCheck; pushStateGuard(); updateLevel = lastAbortCheck = 0; numArgs = 0; parser->getObj(&obj); while (!obj.isEOF()) { commandAborted = gFalse; if (obj.isCmd()) { if (printCommands) { obj.print(stdout); for (i = 0; i < numArgs; ++i) { printf(" "); args[i].print(stdout); } printf("\n"); fflush(stdout); } GooTimer timer; execOp(&obj, args, numArgs); if (profileCommands) { GooHash *hash; hash = out->getProfileHash (); if (hash) { GooString *cmd_g; ProfileData *data_p; cmd_g = new GooString (obj.getCmd()); data_p = (ProfileData *)hash->lookup (cmd_g); if (data_p == NULL) { data_p = new ProfileData(); hash->add (cmd_g, data_p); } data_p->addElement(timer.getElapsed ()); } } obj.free(); for (i = 0; i < numArgs; ++i) args[i].free(); numArgs = 0; if (++updateLevel >= 20000) { out->dump(); updateLevel = 0; } if (commandAborted) { commandAborted = gFalse; break; } if (abortCheckCbk) { if (updateLevel - lastAbortCheck > 10) { if ((*abortCheckCbk)(abortCheckCbkData)) { break; } lastAbortCheck = updateLevel; } } } else if (numArgs < maxArgs) { args[numArgs++] = obj; } else { error(getPos(), "Too many args in content stream"); if (printCommands) { printf("throwing away arg: "); obj.print(stdout); printf("\n"); fflush(stdout); } obj.free(); } parser->getObj(&obj); } obj.free(); if (numArgs > 0) { error(getPos(), "Leftover args in content stream"); if (printCommands) { printf("%d leftovers:", numArgs); for (i = 0; i < numArgs; ++i) { printf(" "); args[i].print(stdout); } printf("\n"); fflush(stdout); } for (i = 0; i < numArgs; ++i) args[i].free(); } popStateGuard(); if (topLevel && updateLevel > 0) { out->dump(); } }
DoS
0
void Gfx::go(GBool topLevel) { Object obj; Object args[maxArgs]; int numArgs, i; int lastAbortCheck; pushStateGuard(); updateLevel = lastAbortCheck = 0; numArgs = 0; parser->getObj(&obj); while (!obj.isEOF()) { commandAborted = gFalse; if (obj.isCmd()) { if (printCommands) { obj.print(stdout); for (i = 0; i < numArgs; ++i) { printf(" "); args[i].print(stdout); } printf("\n"); fflush(stdout); } GooTimer timer; execOp(&obj, args, numArgs); if (profileCommands) { GooHash *hash; hash = out->getProfileHash (); if (hash) { GooString *cmd_g; ProfileData *data_p; cmd_g = new GooString (obj.getCmd()); data_p = (ProfileData *)hash->lookup (cmd_g); if (data_p == NULL) { data_p = new ProfileData(); hash->add (cmd_g, data_p); } data_p->addElement(timer.getElapsed ()); } } obj.free(); for (i = 0; i < numArgs; ++i) args[i].free(); numArgs = 0; if (++updateLevel >= 20000) { out->dump(); updateLevel = 0; } if (commandAborted) { commandAborted = gFalse; break; } if (abortCheckCbk) { if (updateLevel - lastAbortCheck > 10) { if ((*abortCheckCbk)(abortCheckCbkData)) { break; } lastAbortCheck = updateLevel; } } } else if (numArgs < maxArgs) { args[numArgs++] = obj; } else { error(getPos(), "Too many args in content stream"); if (printCommands) { printf("throwing away arg: "); obj.print(stdout); printf("\n"); fflush(stdout); } obj.free(); } parser->getObj(&obj); } obj.free(); if (numArgs > 0) { error(getPos(), "Leftover args in content stream"); if (printCommands) { printf("%d leftovers:", numArgs); for (i = 0; i < numArgs; ++i) { printf(" "); args[i].print(stdout); } printf("\n"); fflush(stdout); } for (i = 0; i < numArgs; ++i) args[i].free(); } popStateGuard(); if (topLevel && updateLevel > 0) { out->dump(); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,436
void Gfx::gouraudFillTriangle(double x0, double y0, GfxColor *color0, double x1, double y1, GfxColor *color1, double x2, double y2, GfxColor *color2, int nComps, int depth) { double x01, y01, x12, y12, x20, y20; GfxColor color01, color12, color20; int i; for (i = 0; i < nComps; ++i) { if (abs(color0->c[i] - color1->c[i]) > gouraudColorDelta || abs(color1->c[i] - color2->c[i]) > gouraudColorDelta) { break; } } if (i == nComps || depth == gouraudMaxDepth) { state->setFillColor(color0); out->updateFillColor(state); state->moveTo(x0, y0); state->lineTo(x1, y1); state->lineTo(x2, y2); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } else { x01 = 0.5 * (x0 + x1); y01 = 0.5 * (y0 + y1); x12 = 0.5 * (x1 + x2); y12 = 0.5 * (y1 + y2); x20 = 0.5 * (x2 + x0); y20 = 0.5 * (y2 + y0); for (i = 0; i < nComps; ++i) { color01.c[i] = (color0->c[i] + color1->c[i]) / 2; color12.c[i] = (color1->c[i] + color2->c[i]) / 2; color20.c[i] = (color2->c[i] + color0->c[i]) / 2; } gouraudFillTriangle(x0, y0, color0, x01, y01, &color01, x20, y20, &color20, nComps, depth + 1); gouraudFillTriangle(x01, y01, &color01, x1, y1, color1, x12, y12, &color12, nComps, depth + 1); gouraudFillTriangle(x01, y01, &color01, x12, y12, &color12, x20, y20, &color20, nComps, depth + 1); gouraudFillTriangle(x20, y20, &color20, x12, y12, &color12, x2, y2, color2, nComps, depth + 1); } }
DoS
0
void Gfx::gouraudFillTriangle(double x0, double y0, GfxColor *color0, double x1, double y1, GfxColor *color1, double x2, double y2, GfxColor *color2, int nComps, int depth) { double x01, y01, x12, y12, x20, y20; GfxColor color01, color12, color20; int i; for (i = 0; i < nComps; ++i) { if (abs(color0->c[i] - color1->c[i]) > gouraudColorDelta || abs(color1->c[i] - color2->c[i]) > gouraudColorDelta) { break; } } if (i == nComps || depth == gouraudMaxDepth) { state->setFillColor(color0); out->updateFillColor(state); state->moveTo(x0, y0); state->lineTo(x1, y1); state->lineTo(x2, y2); state->closePath(); if (!contentIsHidden()) out->fill(state); state->clearPath(); } else { x01 = 0.5 * (x0 + x1); y01 = 0.5 * (y0 + y1); x12 = 0.5 * (x1 + x2); y12 = 0.5 * (y1 + y2); x20 = 0.5 * (x2 + x0); y20 = 0.5 * (y2 + y0); for (i = 0; i < nComps; ++i) { color01.c[i] = (color0->c[i] + color1->c[i]) / 2; color12.c[i] = (color1->c[i] + color2->c[i]) / 2; color20.c[i] = (color2->c[i] + color0->c[i]) / 2; } gouraudFillTriangle(x0, y0, color0, x01, y01, &color01, x20, y20, &color20, nComps, depth + 1); gouraudFillTriangle(x01, y01, &color01, x1, y1, color1, x12, y12, &color12, nComps, depth + 1); gouraudFillTriangle(x01, y01, &color01, x12, y12, &color12, x20, y20, &color20, nComps, depth + 1); gouraudFillTriangle(x20, y20, &color20, x12, y12, &color12, x2, y2, color2, nComps, depth + 1); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,437
static inline GBool isSameGfxColor(const GfxColor &colorA, const GfxColor &colorB, Guint nComps, double delta) { for (Guint k = 0; k < nComps; ++k) { if (abs(colorA.c[k] - colorB.c[k]) > delta) { return false; } } return true; }
DoS
0
static inline GBool isSameGfxColor(const GfxColor &colorA, const GfxColor &colorB, Guint nComps, double delta) { for (Guint k = 0; k < nComps; ++k) { if (abs(colorA.c[k] - colorB.c[k]) > delta) { return false; } } return true; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,438
void GfxResources::lookupColorSpace(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->colorSpaceDict.isDict()) { if (!resPtr->colorSpaceDict.dictLookup(name, obj)->isNull()) { return; } obj->free(); } } obj->initNull(); }
DoS
0
void GfxResources::lookupColorSpace(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->colorSpaceDict.isDict()) { if (!resPtr->colorSpaceDict.dictLookup(name, obj)->isNull()) { return; } obj->free(); } } obj->initNull(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,439
GfxFont *GfxResources::lookupFont(char *name) { GfxFont *font; GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->fonts) { if ((font = resPtr->fonts->lookup(name))) return font; } } error(-1, "Unknown font tag '%s'", name); return NULL; }
DoS
0
GfxFont *GfxResources::lookupFont(char *name) { GfxFont *font; GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->fonts) { if ((font = resPtr->fonts->lookup(name))) return font; } } error(-1, "Unknown font tag '%s'", name); return NULL; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,440
GBool GfxResources::lookupGState(char *name, Object *obj) { if (!lookupGStateNF(name, obj)) return gFalse; if (!obj->isRef()) return gTrue; const Ref ref = obj->getRef(); if (!gStateCache.lookup(ref, obj)->isNull()) return gTrue; obj->free(); gStateCache.put(ref)->copy(obj); return gTrue; }
DoS
0
GBool GfxResources::lookupGState(char *name, Object *obj) { if (!lookupGStateNF(name, obj)) return gFalse; if (!obj->isRef()) return gTrue; const Ref ref = obj->getRef(); if (!gStateCache.lookup(ref, obj)->isNull()) return gTrue; obj->free(); gStateCache.put(ref)->copy(obj); return gTrue; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,441
GBool GfxResources::lookupMarkedContentNF(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->propertiesDict.isDict()) { if (!resPtr->propertiesDict.dictLookupNF(name, obj)->isNull()) return gTrue; obj->free(); } } error(-1, "Marked Content '%s' is unknown", name); return gFalse; }
DoS
0
GBool GfxResources::lookupMarkedContentNF(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->propertiesDict.isDict()) { if (!resPtr->propertiesDict.dictLookupNF(name, obj)->isNull()) return gTrue; obj->free(); } } error(-1, "Marked Content '%s' is unknown", name); return gFalse; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,442
GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) { GfxResources *resPtr; GfxPattern *pattern; Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->patternDict.isDict()) { if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) { pattern = GfxPattern::parse(&obj, gfx); obj.free(); return pattern; } obj.free(); } } error(-1, "Unknown pattern '%s'", name); return NULL; }
DoS
0
GfxPattern *GfxResources::lookupPattern(char *name, Gfx *gfx) { GfxResources *resPtr; GfxPattern *pattern; Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->patternDict.isDict()) { if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) { pattern = GfxPattern::parse(&obj, gfx); obj.free(); return pattern; } obj.free(); } } error(-1, "Unknown pattern '%s'", name); return NULL; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,443
GfxShading *GfxResources::lookupShading(char *name, Gfx *gfx) { GfxResources *resPtr; GfxShading *shading; Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->shadingDict.isDict()) { if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) { shading = GfxShading::parse(&obj, gfx); obj.free(); return shading; } obj.free(); } } error(-1, "Unknown shading '%s'", name); return NULL; }
DoS
0
GfxShading *GfxResources::lookupShading(char *name, Gfx *gfx) { GfxResources *resPtr; GfxShading *shading; Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->shadingDict.isDict()) { if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) { shading = GfxShading::parse(&obj, gfx); obj.free(); return shading; } obj.free(); } } error(-1, "Unknown shading '%s'", name); return NULL; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,444
GBool GfxResources::lookupXObject(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->xObjDict.isDict()) { if (!resPtr->xObjDict.dictLookup(name, obj)->isNull()) return gTrue; obj->free(); } } error(-1, "XObject '%s' is unknown", name); return gFalse; }
DoS
0
GBool GfxResources::lookupXObject(char *name, Object *obj) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->xObjDict.isDict()) { if (!resPtr->xObjDict.dictLookup(name, obj)->isNull()) return gTrue; obj->free(); } } error(-1, "XObject '%s' is unknown", name); return gFalse; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,445
void Gfx::opBeginImage(Object args[], int numArgs) { Stream *str; int c1, c2; str = buildImageStream(); if (str) { doImage(NULL, str, gTrue); c1 = str->getUndecodedStream()->getChar(); c2 = str->getUndecodedStream()->getChar(); while (!(c1 == 'E' && c2 == 'I') && c2 != EOF) { c1 = c2; c2 = str->getUndecodedStream()->getChar(); } delete str; } }
DoS
0
void Gfx::opBeginImage(Object args[], int numArgs) { Stream *str; int c1, c2; str = buildImageStream(); if (str) { doImage(NULL, str, gTrue); c1 = str->getUndecodedStream()->getChar(); c2 = str->getUndecodedStream()->getChar(); while (!(c1 == 'E' && c2 == 'I') && c2 != EOF) { c1 = c2; c2 = str->getUndecodedStream()->getChar(); } delete str; } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,446
void Gfx::opClip(Object args[], int numArgs) { clip = clipNormal; }
DoS
0
void Gfx::opClip(Object args[], int numArgs) { clip = clipNormal; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,447
void Gfx::opCloseEOFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { state->closePath(); if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
DoS
0
void Gfx::opCloseEOFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { state->closePath(); if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,448
void Gfx::opClosePath(Object args[], int numArgs) { if (!state->isCurPt()) { error(getPos(), "No current point in closepath"); return; } state->closePath(); }
DoS
0
void Gfx::opClosePath(Object args[], int numArgs) { if (!state->isCurPt()) { error(getPos(), "No current point in closepath"); return; } state->closePath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,449
void Gfx::opConcat(Object args[], int numArgs) { state->concatCTM(args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); out->updateCTM(state, args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); fontChanged = gTrue; }
DoS
0
void Gfx::opConcat(Object args[], int numArgs) { state->concatCTM(args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); out->updateCTM(state, args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); fontChanged = gTrue; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,450
void Gfx::opCurveTo(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto"); return; } x1 = args[0].getNum(); y1 = args[1].getNum(); x2 = args[2].getNum(); y2 = args[3].getNum(); x3 = args[4].getNum(); y3 = args[5].getNum(); state->curveTo(x1, y1, x2, y2, x3, y3); }
DoS
0
void Gfx::opCurveTo(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto"); return; } x1 = args[0].getNum(); y1 = args[1].getNum(); x2 = args[2].getNum(); y2 = args[3].getNum(); x3 = args[4].getNum(); y3 = args[5].getNum(); state->curveTo(x1, y1, x2, y2, x3, y3); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,451
void Gfx::opCurveTo1(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto1"); return; } x1 = state->getCurX(); y1 = state->getCurY(); x2 = args[0].getNum(); y2 = args[1].getNum(); x3 = args[2].getNum(); y3 = args[3].getNum(); state->curveTo(x1, y1, x2, y2, x3, y3); }
DoS
0
void Gfx::opCurveTo1(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto1"); return; } x1 = state->getCurX(); y1 = state->getCurY(); x2 = args[0].getNum(); y2 = args[1].getNum(); x3 = args[2].getNum(); y3 = args[3].getNum(); state->curveTo(x1, y1, x2, y2, x3, y3); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,452
void Gfx::opCurveTo2(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto2"); return; } x1 = args[0].getNum(); y1 = args[1].getNum(); x2 = args[2].getNum(); y2 = args[3].getNum(); x3 = x2; y3 = y2; state->curveTo(x1, y1, x2, y2, x3, y3); }
DoS
0
void Gfx::opCurveTo2(Object args[], int numArgs) { double x1, y1, x2, y2, x3, y3; if (!state->isCurPt()) { error(getPos(), "No current point in curveto2"); return; } x1 = args[0].getNum(); y1 = args[1].getNum(); x2 = args[2].getNum(); y2 = args[3].getNum(); x3 = x2; y3 = y2; state->curveTo(x1, y1, x2, y2, x3, y3); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,453
void Gfx::opEOClip(Object args[], int numArgs) { clip = clipEO; }
DoS
0
void Gfx::opEOClip(Object args[], int numArgs) { clip = clipEO; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,454
void Gfx::opEOFill(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } } doEndPath(); }
DoS
0
void Gfx::opEOFill(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,455
void Gfx::opEOFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
DoS
0
void Gfx::opEOFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gTrue); } else { out->eoFill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,456
void Gfx::opEndIgnoreUndef(Object args[], int numArgs) { if (ignoreUndef > 0) --ignoreUndef; }
DoS
0
void Gfx::opEndIgnoreUndef(Object args[], int numArgs) { if (ignoreUndef > 0) --ignoreUndef; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,457
void Gfx::opEndImage(Object args[], int numArgs) { error(getPos(), "Internal: got 'EI' operator"); }
DoS
0
void Gfx::opEndImage(Object args[], int numArgs) { error(getPos(), "Internal: got 'EI' operator"); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,458
void Gfx::opEndPath(Object args[], int numArgs) { doEndPath(); }
DoS
0
void Gfx::opEndPath(Object args[], int numArgs) { doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,459
void Gfx::opFill(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gFalse); } else { out->fill(state); } } doEndPath(); }
DoS
0
void Gfx::opFill(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gFalse); } else { out->fill(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,460
void Gfx::opFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gFalse); } else { out->fill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
DoS
0
void Gfx::opFillStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getFillColorSpace()->getMode() == csPattern) { doPatternFill(gFalse); } else { out->fill(state); } if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,461
void Gfx::opImageData(Object args[], int numArgs) { error(getPos(), "Internal: got 'ID' operator"); }
DoS
0
void Gfx::opImageData(Object args[], int numArgs) { error(getPos(), "Internal: got 'ID' operator"); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,462
void Gfx::opLineTo(Object args[], int numArgs) { if (!state->isCurPt()) { error(getPos(), "No current point in lineto"); return; } state->lineTo(args[0].getNum(), args[1].getNum()); }
DoS
0
void Gfx::opLineTo(Object args[], int numArgs) { if (!state->isCurPt()) { error(getPos(), "No current point in lineto"); return; } state->lineTo(args[0].getNum(), args[1].getNum()); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,463
void Gfx::opMoveSetShowText(Object args[], int numArgs) { double tx, ty; if (!state->getFont()) { error(getPos(), "No font in move/set/show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } state->setWordSpace(args[0].getNum()); state->setCharSpace(args[1].getNum()); tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateWordSpace(state); out->updateCharSpace(state); out->updateTextPos(state); out->beginStringOp(state); doShowText(args[2].getString()); out->endStringOp(state); }
DoS
0
void Gfx::opMoveSetShowText(Object args[], int numArgs) { double tx, ty; if (!state->getFont()) { error(getPos(), "No font in move/set/show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } state->setWordSpace(args[0].getNum()); state->setCharSpace(args[1].getNum()); tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateWordSpace(state); out->updateCharSpace(state); out->updateTextPos(state); out->beginStringOp(state); doShowText(args[2].getString()); out->endStringOp(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,464
void Gfx::opMoveShowText(Object args[], int numArgs) { double tx, ty; if (!state->getFont()) { error(getPos(), "No font in move/show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateTextPos(state); out->beginStringOp(state); doShowText(args[0].getString()); out->endStringOp(state); }
DoS
0
void Gfx::opMoveShowText(Object args[], int numArgs) { double tx, ty; if (!state->getFont()) { error(getPos(), "No font in move/show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateTextPos(state); out->beginStringOp(state); doShowText(args[0].getString()); out->endStringOp(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,465
void Gfx::opMoveTo(Object args[], int numArgs) { state->moveTo(args[0].getNum(), args[1].getNum()); }
DoS
0
void Gfx::opMoveTo(Object args[], int numArgs) { state->moveTo(args[0].getNum(), args[1].getNum()); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,466
void Gfx::opRectangle(Object args[], int numArgs) { double x, y, w, h; x = args[0].getNum(); y = args[1].getNum(); w = args[2].getNum(); h = args[3].getNum(); state->moveTo(x, y); state->lineTo(x + w, y); state->lineTo(x + w, y + h); state->lineTo(x, y + h); state->closePath(); }
DoS
0
void Gfx::opRectangle(Object args[], int numArgs) { double x, y, w, h; x = args[0].getNum(); y = args[1].getNum(); w = args[2].getNum(); h = args[3].getNum(); state->moveTo(x, y); state->lineTo(x + w, y); state->lineTo(x + w, y + h); state->lineTo(x, y + h); state->closePath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,467
void Gfx::opRestore(Object args[], int numArgs) { restoreState(); }
DoS
0
void Gfx::opRestore(Object args[], int numArgs) { restoreState(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,468
void Gfx::opSave(Object args[], int numArgs) { saveState(); }
DoS
0
void Gfx::opSave(Object args[], int numArgs) { saveState(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,469
void Gfx::opSetCacheDevice(Object args[], int numArgs) { out->type3D1(state, args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); }
DoS
0
void Gfx::opSetCacheDevice(Object args[], int numArgs) { out->type3D1(state, args[0].getNum(), args[1].getNum(), args[2].getNum(), args[3].getNum(), args[4].getNum(), args[5].getNum()); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,470
void Gfx::opSetCharSpacing(Object args[], int numArgs) { state->setCharSpace(args[0].getNum()); out->updateCharSpace(state); }
DoS
0
void Gfx::opSetCharSpacing(Object args[], int numArgs) { state->setCharSpace(args[0].getNum()); out->updateCharSpace(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,471
void Gfx::opSetCharWidth(Object args[], int numArgs) { out->type3D0(state, args[0].getNum(), args[1].getNum()); }
DoS
0
void Gfx::opSetCharWidth(Object args[], int numArgs) { out->type3D0(state, args[0].getNum(), args[1].getNum()); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,472
void Gfx::opSetDash(Object args[], int numArgs) { Array *a; int length; Object obj; double *dash; int i; a = args[0].getArray(); length = a->getLength(); if (length == 0) { dash = NULL; } else { dash = (double *)gmallocn(length, sizeof(double)); for (i = 0; i < length; ++i) { dash[i] = a->get(i, &obj)->getNum(); obj.free(); } } state->setLineDash(dash, length, args[1].getNum()); out->updateLineDash(state); }
DoS
0
void Gfx::opSetDash(Object args[], int numArgs) { Array *a; int length; Object obj; double *dash; int i; a = args[0].getArray(); length = a->getLength(); if (length == 0) { dash = NULL; } else { dash = (double *)gmallocn(length, sizeof(double)); for (i = 0; i < length; ++i) { dash[i] = a->get(i, &obj)->getNum(); obj.free(); } } state->setLineDash(dash, length, args[1].getNum()); out->updateLineDash(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,473
void Gfx::opSetExtGState(Object args[], int numArgs) { Object obj1, obj2, obj3, obj4, obj5; GfxBlendMode mode; GBool haveFillOP; Function *funcs[4]; GfxColor backdropColor; GBool haveBackdropColor; GfxColorSpace *blendingColorSpace; GBool alpha, isolated, knockout; int i; if (!res->lookupGState(args[0].getName(), &obj1)) { return; } if (!obj1.isDict()) { error(getPos(), "ExtGState '%s' is wrong type", args[0].getName()); obj1.free(); return; } if (printCommands) { printf(" gfx state dict: "); obj1.print(); printf("\n"); } if (!obj1.dictLookup("BM", &obj2)->isNull()) { if (state->parseBlendMode(&obj2, &mode)) { state->setBlendMode(mode); out->updateBlendMode(state); } else { error(getPos(), "Invalid blend mode in ExtGState"); } } obj2.free(); if (obj1.dictLookup("ca", &obj2)->isNum()) { state->setFillOpacity(obj2.getNum()); out->updateFillOpacity(state); } obj2.free(); if (obj1.dictLookup("CA", &obj2)->isNum()) { state->setStrokeOpacity(obj2.getNum()); out->updateStrokeOpacity(state); } obj2.free(); if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) { state->setFillOverprint(obj2.getBool()); out->updateFillOverprint(state); } obj2.free(); if (obj1.dictLookup("OP", &obj2)->isBool()) { state->setStrokeOverprint(obj2.getBool()); out->updateStrokeOverprint(state); if (!haveFillOP) { state->setFillOverprint(obj2.getBool()); out->updateFillOverprint(state); } } obj2.free(); if (obj1.dictLookup("SA", &obj2)->isBool()) { state->setStrokeAdjust(obj2.getBool()); out->updateStrokeAdjust(state); } obj2.free(); if (obj1.dictLookup("TR2", &obj2)->isNull()) { obj2.free(); obj1.dictLookup("TR", &obj2); } if (obj2.isName("Default") || obj2.isName("Identity")) { funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL; state->setTransfer(funcs); out->updateTransfer(state); } else if (obj2.isArray() && obj2.arrayGetLength() == 4) { for (i = 0; i < 4; ++i) { obj2.arrayGet(i, &obj3); funcs[i] = Function::parse(&obj3); obj3.free(); if (!funcs[i]) { break; } } if (i == 4) { state->setTransfer(funcs); out->updateTransfer(state); } } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) { if ((funcs[0] = Function::parse(&obj2))) { funcs[1] = funcs[2] = funcs[3] = NULL; state->setTransfer(funcs); out->updateTransfer(state); } } else if (!obj2.isNull()) { error(getPos(), "Invalid transfer function in ExtGState"); } obj2.free(); if (obj1.dictLookup("AIS", &obj2)->isBool()) { state->setAlphaIsShape(obj2.getBool()); out->updateAlphaIsShape(state); } obj2.free(); if (obj1.dictLookup("TK", &obj2)->isBool()) { state->setTextKnockout(obj2.getBool()); out->updateTextKnockout(state); } obj2.free(); if (!obj1.dictLookup("SMask", &obj2)->isNull()) { if (obj2.isName("None")) { out->clearSoftMask(state); } else if (obj2.isDict()) { if (obj2.dictLookup("S", &obj3)->isName("Alpha")) { alpha = gTrue; } else { // "Luminosity" alpha = gFalse; } obj3.free(); funcs[0] = NULL; if (!obj2.dictLookup("TR", &obj3)->isNull()) { funcs[0] = Function::parse(&obj3); if (funcs[0]->getInputSize() != 1 || funcs[0]->getOutputSize() != 1) { error(getPos(), "Invalid transfer function in soft mask in ExtGState"); delete funcs[0]; funcs[0] = NULL; } } obj3.free(); if ((haveBackdropColor = obj2.dictLookup("BC", &obj3)->isArray())) { for (i = 0; i < gfxColorMaxComps; ++i) { backdropColor.c[i] = 0; } for (i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) { obj3.arrayGet(i, &obj4); if (obj4.isNum()) { backdropColor.c[i] = dblToCol(obj4.getNum()); } obj4.free(); } } obj3.free(); if (obj2.dictLookup("G", &obj3)->isStream()) { if (obj3.streamGetDict()->lookup("Group", &obj4)->isDict()) { blendingColorSpace = NULL; isolated = knockout = gFalse; if (!obj4.dictLookup("CS", &obj5)->isNull()) { blendingColorSpace = GfxColorSpace::parse(&obj5, this); } obj5.free(); if (obj4.dictLookup("I", &obj5)->isBool()) { isolated = obj5.getBool(); } obj5.free(); if (obj4.dictLookup("K", &obj5)->isBool()) { knockout = obj5.getBool(); } obj5.free(); if (!haveBackdropColor) { if (blendingColorSpace) { blendingColorSpace->getDefaultColor(&backdropColor); } else { for (i = 0; i < gfxColorMaxComps; ++i) { backdropColor.c[i] = 0; } } } doSoftMask(&obj3, alpha, blendingColorSpace, isolated, knockout, funcs[0], &backdropColor); if (funcs[0]) { delete funcs[0]; } } else { error(getPos(), "Invalid soft mask in ExtGState - missing group"); } obj4.free(); } else { error(getPos(), "Invalid soft mask in ExtGState - missing group"); } obj3.free(); } else if (!obj2.isNull()) { error(getPos(), "Invalid soft mask in ExtGState"); } } obj2.free(); if (obj1.dictLookup("Font", &obj2)->isArray()) { GfxFont *font; if (obj2.arrayGetLength() == 2) { Object fargs0, fargs1; obj2.arrayGetNF(0,&fargs0); obj2.arrayGet(1,&fargs1); if (fargs0.isRef() && fargs1.isNum()) { Object fobj; Ref r; fargs0.fetch(xref, &fobj); if (fobj.isDict()) { r = fargs0.getRef(); font = GfxFont::makeFont(xref,args[0].getName(),r,fobj.getDict()); state->setFont(font,fargs1.getNum()); fontChanged = gTrue; } fobj.free(); } fargs0.free(); fargs1.free(); } else { error(getPos(), "Number of args mismatch for /Font in ExtGState"); } } obj2.free(); if (obj1.dictLookup("LW", &obj2)->isNum()) { opSetLineWidth(&obj2,1); } obj2.free(); if (obj1.dictLookup("LC", &obj2)->isInt()) { opSetLineCap(&obj2,1); } obj2.free(); if (obj1.dictLookup("LJ", &obj2)->isInt()) { opSetLineJoin(&obj2,1); } obj2.free(); if (obj1.dictLookup("ML", &obj2)->isNum()) { opSetMiterLimit(&obj2,1); } obj2.free(); if (obj1.dictLookup("D", &obj2)->isArray()) { if (obj2.arrayGetLength() == 2) { Object dargs[2]; obj2.arrayGetNF(0,&dargs[0]); obj2.arrayGet(1,&dargs[1]); if (dargs[0].isArray() && dargs[1].isInt()) { opSetDash(dargs,2); } dargs[0].free(); dargs[1].free(); } else { error(getPos(), "Number of args mismatch for /D in ExtGState"); } } obj2.free(); if (obj1.dictLookup("RI", &obj2)->isName()) { opSetRenderingIntent(&obj2,1); } obj2.free(); if (obj1.dictLookup("FL", &obj2)->isNum()) { opSetFlat(&obj2,1); } obj2.free(); obj1.free(); }
DoS
0
void Gfx::opSetExtGState(Object args[], int numArgs) { Object obj1, obj2, obj3, obj4, obj5; GfxBlendMode mode; GBool haveFillOP; Function *funcs[4]; GfxColor backdropColor; GBool haveBackdropColor; GfxColorSpace *blendingColorSpace; GBool alpha, isolated, knockout; int i; if (!res->lookupGState(args[0].getName(), &obj1)) { return; } if (!obj1.isDict()) { error(getPos(), "ExtGState '%s' is wrong type", args[0].getName()); obj1.free(); return; } if (printCommands) { printf(" gfx state dict: "); obj1.print(); printf("\n"); } if (!obj1.dictLookup("BM", &obj2)->isNull()) { if (state->parseBlendMode(&obj2, &mode)) { state->setBlendMode(mode); out->updateBlendMode(state); } else { error(getPos(), "Invalid blend mode in ExtGState"); } } obj2.free(); if (obj1.dictLookup("ca", &obj2)->isNum()) { state->setFillOpacity(obj2.getNum()); out->updateFillOpacity(state); } obj2.free(); if (obj1.dictLookup("CA", &obj2)->isNum()) { state->setStrokeOpacity(obj2.getNum()); out->updateStrokeOpacity(state); } obj2.free(); if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) { state->setFillOverprint(obj2.getBool()); out->updateFillOverprint(state); } obj2.free(); if (obj1.dictLookup("OP", &obj2)->isBool()) { state->setStrokeOverprint(obj2.getBool()); out->updateStrokeOverprint(state); if (!haveFillOP) { state->setFillOverprint(obj2.getBool()); out->updateFillOverprint(state); } } obj2.free(); if (obj1.dictLookup("SA", &obj2)->isBool()) { state->setStrokeAdjust(obj2.getBool()); out->updateStrokeAdjust(state); } obj2.free(); if (obj1.dictLookup("TR2", &obj2)->isNull()) { obj2.free(); obj1.dictLookup("TR", &obj2); } if (obj2.isName("Default") || obj2.isName("Identity")) { funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL; state->setTransfer(funcs); out->updateTransfer(state); } else if (obj2.isArray() && obj2.arrayGetLength() == 4) { for (i = 0; i < 4; ++i) { obj2.arrayGet(i, &obj3); funcs[i] = Function::parse(&obj3); obj3.free(); if (!funcs[i]) { break; } } if (i == 4) { state->setTransfer(funcs); out->updateTransfer(state); } } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) { if ((funcs[0] = Function::parse(&obj2))) { funcs[1] = funcs[2] = funcs[3] = NULL; state->setTransfer(funcs); out->updateTransfer(state); } } else if (!obj2.isNull()) { error(getPos(), "Invalid transfer function in ExtGState"); } obj2.free(); if (obj1.dictLookup("AIS", &obj2)->isBool()) { state->setAlphaIsShape(obj2.getBool()); out->updateAlphaIsShape(state); } obj2.free(); if (obj1.dictLookup("TK", &obj2)->isBool()) { state->setTextKnockout(obj2.getBool()); out->updateTextKnockout(state); } obj2.free(); if (!obj1.dictLookup("SMask", &obj2)->isNull()) { if (obj2.isName("None")) { out->clearSoftMask(state); } else if (obj2.isDict()) { if (obj2.dictLookup("S", &obj3)->isName("Alpha")) { alpha = gTrue; } else { // "Luminosity" alpha = gFalse; } obj3.free(); funcs[0] = NULL; if (!obj2.dictLookup("TR", &obj3)->isNull()) { funcs[0] = Function::parse(&obj3); if (funcs[0]->getInputSize() != 1 || funcs[0]->getOutputSize() != 1) { error(getPos(), "Invalid transfer function in soft mask in ExtGState"); delete funcs[0]; funcs[0] = NULL; } } obj3.free(); if ((haveBackdropColor = obj2.dictLookup("BC", &obj3)->isArray())) { for (i = 0; i < gfxColorMaxComps; ++i) { backdropColor.c[i] = 0; } for (i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) { obj3.arrayGet(i, &obj4); if (obj4.isNum()) { backdropColor.c[i] = dblToCol(obj4.getNum()); } obj4.free(); } } obj3.free(); if (obj2.dictLookup("G", &obj3)->isStream()) { if (obj3.streamGetDict()->lookup("Group", &obj4)->isDict()) { blendingColorSpace = NULL; isolated = knockout = gFalse; if (!obj4.dictLookup("CS", &obj5)->isNull()) { blendingColorSpace = GfxColorSpace::parse(&obj5, this); } obj5.free(); if (obj4.dictLookup("I", &obj5)->isBool()) { isolated = obj5.getBool(); } obj5.free(); if (obj4.dictLookup("K", &obj5)->isBool()) { knockout = obj5.getBool(); } obj5.free(); if (!haveBackdropColor) { if (blendingColorSpace) { blendingColorSpace->getDefaultColor(&backdropColor); } else { for (i = 0; i < gfxColorMaxComps; ++i) { backdropColor.c[i] = 0; } } } doSoftMask(&obj3, alpha, blendingColorSpace, isolated, knockout, funcs[0], &backdropColor); if (funcs[0]) { delete funcs[0]; } } else { error(getPos(), "Invalid soft mask in ExtGState - missing group"); } obj4.free(); } else { error(getPos(), "Invalid soft mask in ExtGState - missing group"); } obj3.free(); } else if (!obj2.isNull()) { error(getPos(), "Invalid soft mask in ExtGState"); } } obj2.free(); if (obj1.dictLookup("Font", &obj2)->isArray()) { GfxFont *font; if (obj2.arrayGetLength() == 2) { Object fargs0, fargs1; obj2.arrayGetNF(0,&fargs0); obj2.arrayGet(1,&fargs1); if (fargs0.isRef() && fargs1.isNum()) { Object fobj; Ref r; fargs0.fetch(xref, &fobj); if (fobj.isDict()) { r = fargs0.getRef(); font = GfxFont::makeFont(xref,args[0].getName(),r,fobj.getDict()); state->setFont(font,fargs1.getNum()); fontChanged = gTrue; } fobj.free(); } fargs0.free(); fargs1.free(); } else { error(getPos(), "Number of args mismatch for /Font in ExtGState"); } } obj2.free(); if (obj1.dictLookup("LW", &obj2)->isNum()) { opSetLineWidth(&obj2,1); } obj2.free(); if (obj1.dictLookup("LC", &obj2)->isInt()) { opSetLineCap(&obj2,1); } obj2.free(); if (obj1.dictLookup("LJ", &obj2)->isInt()) { opSetLineJoin(&obj2,1); } obj2.free(); if (obj1.dictLookup("ML", &obj2)->isNum()) { opSetMiterLimit(&obj2,1); } obj2.free(); if (obj1.dictLookup("D", &obj2)->isArray()) { if (obj2.arrayGetLength() == 2) { Object dargs[2]; obj2.arrayGetNF(0,&dargs[0]); obj2.arrayGet(1,&dargs[1]); if (dargs[0].isArray() && dargs[1].isInt()) { opSetDash(dargs,2); } dargs[0].free(); dargs[1].free(); } else { error(getPos(), "Number of args mismatch for /D in ExtGState"); } } obj2.free(); if (obj1.dictLookup("RI", &obj2)->isName()) { opSetRenderingIntent(&obj2,1); } obj2.free(); if (obj1.dictLookup("FL", &obj2)->isNum()) { opSetFlat(&obj2,1); } obj2.free(); obj1.free(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,474
void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { GfxColor color; int i; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceCMYKColorSpace()); out->updateFillColorSpace(state); for (i = 0; i < 4; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
DoS
0
void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { GfxColor color; int i; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceCMYKColorSpace()); out->updateFillColorSpace(state); for (i = 0; i < 4; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,475
void Gfx::opSetFillColorN(Object args[], int numArgs) { GfxColor color; GfxPattern *pattern; int i; if (state->getFillColorSpace()->getMode() == csPattern) { if (numArgs > 1) { if (!((GfxPatternColorSpace *)state->getFillColorSpace())->getUnder() || numArgs - 1 != ((GfxPatternColorSpace *)state->getFillColorSpace()) ->getUnder()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'scn' command"); return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setFillColor(&color); out->updateFillColor(state); } if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName(), this))) { state->setFillPattern(pattern); } } else { if (numArgs != state->getFillColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'scn' command"); return; } state->setFillPattern(NULL); for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setFillColor(&color); out->updateFillColor(state); } }
DoS
0
void Gfx::opSetFillColorN(Object args[], int numArgs) { GfxColor color; GfxPattern *pattern; int i; if (state->getFillColorSpace()->getMode() == csPattern) { if (numArgs > 1) { if (!((GfxPatternColorSpace *)state->getFillColorSpace())->getUnder() || numArgs - 1 != ((GfxPatternColorSpace *)state->getFillColorSpace()) ->getUnder()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'scn' command"); return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setFillColor(&color); out->updateFillColor(state); } if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName(), this))) { state->setFillPattern(pattern); } } else { if (numArgs != state->getFillColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'scn' command"); return; } state->setFillPattern(NULL); for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setFillColor(&color); out->updateFillColor(state); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,476
void Gfx::opSetFillColorSpace(Object args[], int numArgs) { Object obj; GfxColorSpace *colorSpace; GfxColor color; res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0], this); } else { colorSpace = GfxColorSpace::parse(&obj, this); } obj.free(); if (colorSpace) { if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(colorSpace); out->updateFillColorSpace(state); colorSpace->getDefaultColor(&color); state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = colorSpace->getMode() == csPattern; } else if (drawText && out->supportTextCSPattern(state)) { out->beginTextObject(state); textHaveCSPattern = gTrue; } } else { error(getPos(), "Bad color space (fill)"); } }
DoS
0
void Gfx::opSetFillColorSpace(Object args[], int numArgs) { Object obj; GfxColorSpace *colorSpace; GfxColor color; res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0], this); } else { colorSpace = GfxColorSpace::parse(&obj, this); } obj.free(); if (colorSpace) { if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(colorSpace); out->updateFillColorSpace(state); colorSpace->getDefaultColor(&color); state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = colorSpace->getMode() == csPattern; } else if (drawText && out->supportTextCSPattern(state)) { out->beginTextObject(state); textHaveCSPattern = gTrue; } } else { error(getPos(), "Bad color space (fill)"); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,477
void Gfx::opSetFillGray(Object args[], int numArgs) { GfxColor color; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceGrayColorSpace()); out->updateFillColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
DoS
0
void Gfx::opSetFillGray(Object args[], int numArgs) { GfxColor color; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceGrayColorSpace()); out->updateFillColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,478
void Gfx::opSetFillRGBColor(Object args[], int numArgs) { GfxColor color; int i; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceRGBColorSpace()); out->updateFillColorSpace(state); for (i = 0; i < 3; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
DoS
0
void Gfx::opSetFillRGBColor(Object args[], int numArgs) { GfxColor color; int i; if (textHaveCSPattern && drawText) { GBool needFill = out->deviceHasTextClip(state); out->endTextObject(state); if (needFill) { doPatternFill(gTrue); } out->restoreState(state); } state->setFillPattern(NULL); state->setFillColorSpace(new GfxDeviceRGBColorSpace()); out->updateFillColorSpace(state); for (i = 0; i < 3; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setFillColor(&color); out->updateFillColor(state); if (textHaveCSPattern) { out->beginTextObject(state); out->updateRender(state); out->updateTextMat(state); out->updateTextPos(state); textHaveCSPattern = gFalse; } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,479
void Gfx::opSetFlat(Object args[], int numArgs) { state->setFlatness((int)args[0].getNum()); out->updateFlatness(state); }
DoS
0
void Gfx::opSetFlat(Object args[], int numArgs) { state->setFlatness((int)args[0].getNum()); out->updateFlatness(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,480
void Gfx::opSetFont(Object args[], int numArgs) { GfxFont *font; if (!(font = res->lookupFont(args[0].getName()))) { state->setFont(NULL, args[1].getNum()); fontChanged = gTrue; return; } if (printCommands) { printf(" font: tag=%s name='%s' %g\n", font->getTag()->getCString(), font->getName() ? font->getName()->getCString() : "???", args[1].getNum()); fflush(stdout); } font->incRefCnt(); state->setFont(font, args[1].getNum()); fontChanged = gTrue; }
DoS
0
void Gfx::opSetFont(Object args[], int numArgs) { GfxFont *font; if (!(font = res->lookupFont(args[0].getName()))) { state->setFont(NULL, args[1].getNum()); fontChanged = gTrue; return; } if (printCommands) { printf(" font: tag=%s name='%s' %g\n", font->getTag()->getCString(), font->getName() ? font->getName()->getCString() : "???", args[1].getNum()); fflush(stdout); } font->incRefCnt(); state->setFont(font, args[1].getNum()); fontChanged = gTrue; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,481
void Gfx::opSetHorizScaling(Object args[], int numArgs) { state->setHorizScaling(args[0].getNum()); out->updateHorizScaling(state); fontChanged = gTrue; }
DoS
0
void Gfx::opSetHorizScaling(Object args[], int numArgs) { state->setHorizScaling(args[0].getNum()); out->updateHorizScaling(state); fontChanged = gTrue; }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,482
void Gfx::opSetLineCap(Object args[], int numArgs) { state->setLineCap(args[0].getInt()); out->updateLineCap(state); }
DoS
0
void Gfx::opSetLineCap(Object args[], int numArgs) { state->setLineCap(args[0].getInt()); out->updateLineCap(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,483
void Gfx::opSetLineJoin(Object args[], int numArgs) { state->setLineJoin(args[0].getInt()); out->updateLineJoin(state); }
DoS
0
void Gfx::opSetLineJoin(Object args[], int numArgs) { state->setLineJoin(args[0].getInt()); out->updateLineJoin(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,484
void Gfx::opSetLineWidth(Object args[], int numArgs) { state->setLineWidth(args[0].getNum()); out->updateLineWidth(state); }
DoS
0
void Gfx::opSetLineWidth(Object args[], int numArgs) { state->setLineWidth(args[0].getNum()); out->updateLineWidth(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,485
void Gfx::opSetMiterLimit(Object args[], int numArgs) { state->setMiterLimit(args[0].getNum()); out->updateMiterLimit(state); }
DoS
0
void Gfx::opSetMiterLimit(Object args[], int numArgs) { state->setMiterLimit(args[0].getNum()); out->updateMiterLimit(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,486
void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { GfxColor color; int i; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceCMYKColorSpace()); out->updateStrokeColorSpace(state); for (i = 0; i < 4; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
DoS
0
void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { GfxColor color; int i; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceCMYKColorSpace()); out->updateStrokeColorSpace(state); for (i = 0; i < 4; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,487
void Gfx::opSetStrokeColor(Object args[], int numArgs) { GfxColor color; int i; if (numArgs != state->getStrokeColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SC' command"); return; } state->setStrokePattern(NULL); for (i = 0; i < numArgs; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
DoS
0
void Gfx::opSetStrokeColor(Object args[], int numArgs) { GfxColor color; int i; if (numArgs != state->getStrokeColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SC' command"); return; } state->setStrokePattern(NULL); for (i = 0; i < numArgs; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,488
void Gfx::opSetStrokeColorN(Object args[], int numArgs) { GfxColor color; GfxPattern *pattern; int i; if (state->getStrokeColorSpace()->getMode() == csPattern) { if (numArgs > 1) { if (!((GfxPatternColorSpace *)state->getStrokeColorSpace()) ->getUnder() || numArgs - 1 != ((GfxPatternColorSpace *)state->getStrokeColorSpace()) ->getUnder()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SCN' command"); return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setStrokeColor(&color); out->updateStrokeColor(state); } if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName(), this))) { state->setStrokePattern(pattern); } } else { if (numArgs != state->getStrokeColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SCN' command"); return; } state->setStrokePattern(NULL); for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setStrokeColor(&color); out->updateStrokeColor(state); } }
DoS
0
void Gfx::opSetStrokeColorN(Object args[], int numArgs) { GfxColor color; GfxPattern *pattern; int i; if (state->getStrokeColorSpace()->getMode() == csPattern) { if (numArgs > 1) { if (!((GfxPatternColorSpace *)state->getStrokeColorSpace()) ->getUnder() || numArgs - 1 != ((GfxPatternColorSpace *)state->getStrokeColorSpace()) ->getUnder()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SCN' command"); return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setStrokeColor(&color); out->updateStrokeColor(state); } if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName(), this))) { state->setStrokePattern(pattern); } } else { if (numArgs != state->getStrokeColorSpace()->getNComps()) { error(getPos(), "Incorrect number of arguments in 'SCN' command"); return; } state->setStrokePattern(NULL); for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) { if (args[i].isNum()) { color.c[i] = dblToCol(args[i].getNum()); } } state->setStrokeColor(&color); out->updateStrokeColor(state); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,489
void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) { Object obj; GfxColorSpace *colorSpace; GfxColor color; state->setStrokePattern(NULL); res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0], this); } else { colorSpace = GfxColorSpace::parse(&obj, this); } obj.free(); if (colorSpace) { state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); colorSpace->getDefaultColor(&color); state->setStrokeColor(&color); out->updateStrokeColor(state); } else { error(getPos(), "Bad color space (stroke)"); } }
DoS
0
void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) { Object obj; GfxColorSpace *colorSpace; GfxColor color; state->setStrokePattern(NULL); res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0], this); } else { colorSpace = GfxColorSpace::parse(&obj, this); } obj.free(); if (colorSpace) { state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); colorSpace->getDefaultColor(&color); state->setStrokeColor(&color); out->updateStrokeColor(state); } else { error(getPos(), "Bad color space (stroke)"); } }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,490
void Gfx::opSetStrokeGray(Object args[], int numArgs) { GfxColor color; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceGrayColorSpace()); out->updateStrokeColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); state->setStrokeColor(&color); out->updateStrokeColor(state); }
DoS
0
void Gfx::opSetStrokeGray(Object args[], int numArgs) { GfxColor color; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceGrayColorSpace()); out->updateStrokeColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); state->setStrokeColor(&color); out->updateStrokeColor(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,491
void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { GfxColor color; int i; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceRGBColorSpace()); out->updateStrokeColorSpace(state); for (i = 0; i < 3; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
DoS
0
void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { GfxColor color; int i; state->setStrokePattern(NULL); state->setStrokeColorSpace(new GfxDeviceRGBColorSpace()); out->updateStrokeColorSpace(state); for (i = 0; i < 3; ++i) { color.c[i] = dblToCol(args[i].getNum()); } state->setStrokeColor(&color); out->updateStrokeColor(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,492
void Gfx::opSetTextLeading(Object args[], int numArgs) { state->setLeading(args[0].getNum()); }
DoS
0
void Gfx::opSetTextLeading(Object args[], int numArgs) { state->setLeading(args[0].getNum()); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,493
void Gfx::opSetTextRise(Object args[], int numArgs) { state->setRise(args[0].getNum()); out->updateRise(state); }
DoS
0
void Gfx::opSetTextRise(Object args[], int numArgs) { state->setRise(args[0].getNum()); out->updateRise(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,494
void Gfx::opSetWordSpacing(Object args[], int numArgs) { state->setWordSpace(args[0].getNum()); out->updateWordSpace(state); }
DoS
0
void Gfx::opSetWordSpacing(Object args[], int numArgs) { state->setWordSpace(args[0].getNum()); out->updateWordSpace(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,495
void Gfx::opShowSpaceText(Object args[], int numArgs) { Array *a; Object obj; int wMode; int i; if (!state->getFont()) { error(getPos(), "No font in show/space"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } out->beginStringOp(state); wMode = state->getFont()->getWMode(); a = args[0].getArray(); for (i = 0; i < a->getLength(); ++i) { a->get(i, &obj); if (obj.isNum()) { if (wMode) { state->textShift(0, -obj.getNum() * 0.001 * fabs(state->getFontSize())); } else { state->textShift(-obj.getNum() * 0.001 * fabs(state->getFontSize()), 0); } out->updateTextShift(state, obj.getNum()); } else if (obj.isString()) { doShowText(obj.getString()); } else { error(getPos(), "Element of show/space array must be number or string"); } obj.free(); } out->endStringOp(state); }
DoS
0
void Gfx::opShowSpaceText(Object args[], int numArgs) { Array *a; Object obj; int wMode; int i; if (!state->getFont()) { error(getPos(), "No font in show/space"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } out->beginStringOp(state); wMode = state->getFont()->getWMode(); a = args[0].getArray(); for (i = 0; i < a->getLength(); ++i) { a->get(i, &obj); if (obj.isNum()) { if (wMode) { state->textShift(0, -obj.getNum() * 0.001 * fabs(state->getFontSize())); } else { state->textShift(-obj.getNum() * 0.001 * fabs(state->getFontSize()), 0); } out->updateTextShift(state, obj.getNum()); } else if (obj.isString()) { doShowText(obj.getString()); } else { error(getPos(), "Element of show/space array must be number or string"); } obj.free(); } out->endStringOp(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,496
void Gfx::opShowText(Object args[], int numArgs) { if (!state->getFont()) { error(getPos(), "No font in show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } out->beginStringOp(state); doShowText(args[0].getString()); out->endStringOp(state); }
DoS
0
void Gfx::opShowText(Object args[], int numArgs) { if (!state->getFont()) { error(getPos(), "No font in show"); return; } if (fontChanged) { out->updateFont(state); fontChanged = gFalse; } out->beginStringOp(state); doShowText(args[0].getString()); out->endStringOp(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,497
void Gfx::opStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
DoS
0
void Gfx::opStroke(Object args[], int numArgs) { if (!state->isCurPt()) { return; } if (state->isPath() && !contentIsHidden()) { if (state->getStrokeColorSpace()->getMode() == csPattern) { doPatternStroke(); } else { out->stroke(state); } } doEndPath(); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,498
void Gfx::opTextMoveSet(Object args[], int numArgs) { double tx, ty; tx = state->getLineX() + args[0].getNum(); ty = args[1].getNum(); state->setLeading(-ty); ty += state->getLineY(); state->textMoveTo(tx, ty); out->updateTextPos(state); }
DoS
0
void Gfx::opTextMoveSet(Object args[], int numArgs) { double tx, ty; tx = state->getLineX() + args[0].getNum(); ty = args[1].getNum(); state->setLeading(-ty); ty += state->getLineY(); state->textMoveTo(tx, ty); out->updateTextPos(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null
6,499
void Gfx::opTextNextLine(Object args[], int numArgs) { double tx, ty; tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateTextPos(state); }
DoS
0
void Gfx::opTextNextLine(Object args[], int numArgs) { double tx, ty; tx = state->getLineX(); ty = state->getLineY() - state->getLeading(); state->textMoveTo(tx, ty); out->updateTextPos(state); }
@@ -536,6 +536,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *cata drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL); @@ -590,6 +591,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalogA, drawText = gFalse; maskHaveCSPattern = gFalse; mcStack = NULL; + parser = NULL; // start the resource stack res = new GfxResources(xref, resDict, NULL);
CWE-20
null
null