idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
900
GfxShadingBitBuf::~GfxShadingBitBuf() { str->close(); }
DoS Exec Code Overflow
0
GfxShadingBitBuf::~GfxShadingBitBuf() { str->close(); }
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) int i, j, n; n = base->getNComps(); - line = (Guchar *) gmalloc (length * n); + line = (Guchar *) gmallocn (length, n); for (i = 0; i < length; i++) for (j = 0; j < n; j++) line[i * n + j] = lookup[in[i] * n + j]; @@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps2 = colorSpace2->getNComps(); lookup2 = indexedCS->getLookup(); colorSpace2->getDefaultRanges(x, y, indexHigh); - byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); + byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); for (k = 0; k < nComps2; ++k) { lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, sizeof(GfxColorComp)); @@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; @@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];
CWE-189
null
null
901
GfxShadingPattern::~GfxShadingPattern() { delete shading; }
DoS Exec Code Overflow
0
GfxShadingPattern::~GfxShadingPattern() { delete shading; }
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) int i, j, n; n = base->getNComps(); - line = (Guchar *) gmalloc (length * n); + line = (Guchar *) gmallocn (length, n); for (i = 0; i < length; i++) for (j = 0; j < n; j++) line[i * n + j] = lookup[in[i] * n + j]; @@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps2 = colorSpace2->getNComps(); lookup2 = indexedCS->getLookup(); colorSpace2->getDefaultRanges(x, y, indexHigh); - byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); + byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); for (k = 0; k < nComps2; ++k) { lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, sizeof(GfxColorComp)); @@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; @@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];
CWE-189
null
null
902
GfxState::~GfxState() { int i; if (fillColorSpace) { delete fillColorSpace; } if (strokeColorSpace) { delete strokeColorSpace; } if (fillPattern) { delete fillPattern; } if (strokePattern) { delete strokePattern; } for (i = 0; i < 4; ++i) { if (transfer[i]) { delete transfer[i]; } } gfree(lineDash); if (path) { delete path; } if (saved) { delete saved; } if (font) { font->decRefCnt(); } }
DoS Exec Code Overflow
0
GfxState::~GfxState() { int i; if (fillColorSpace) { delete fillColorSpace; } if (strokeColorSpace) { delete strokeColorSpace; } if (fillPattern) { delete fillPattern; } if (strokePattern) { delete strokePattern; } for (i = 0; i < 4; ++i) { if (transfer[i]) { delete transfer[i]; } } gfree(lineDash); if (path) { delete path; } if (saved) { delete saved; } if (font) { font->decRefCnt(); } }
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) int i, j, n; n = base->getNComps(); - line = (Guchar *) gmalloc (length * n); + line = (Guchar *) gmallocn (length, n); for (i = 0; i < length; i++) for (j = 0; j < n; j++) line[i * n + j] = lookup[in[i] * n + j]; @@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps2 = colorSpace2->getNComps(); lookup2 = indexedCS->getLookup(); colorSpace2->getDefaultRanges(x, y, indexHigh); - byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); + byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); for (k = 0; k < nComps2; ++k) { lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, sizeof(GfxColorComp)); @@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; @@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];
CWE-189
null
null
903
GfxSubpath::~GfxSubpath() { gfree(x); gfree(y); gfree(curve); }
DoS Exec Code Overflow
0
GfxSubpath::~GfxSubpath() { gfree(x); gfree(y); gfree(curve); }
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) int i, j, n; n = base->getNComps(); - line = (Guchar *) gmalloc (length * n); + line = (Guchar *) gmallocn (length, n); for (i = 0; i < length; i++) for (j = 0; j < n; j++) line[i * n + j] = lookup[in[i] * n + j]; @@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps2 = colorSpace2->getNComps(); lookup2 = indexedCS->getLookup(); colorSpace2->getDefaultRanges(x, y, indexHigh); - byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); + byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); for (k = 0; k < nComps2; ++k) { lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, sizeof(GfxColorComp)); @@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; @@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];
CWE-189
null
null
904
GfxTilingPattern::~GfxTilingPattern() { resDict.free(); contentStream.free(); }
DoS Exec Code Overflow
0
GfxTilingPattern::~GfxTilingPattern() { resDict.free(); contentStream.free(); }
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) int i, j, n; n = base->getNComps(); - line = (Guchar *) gmalloc (length * n); + line = (Guchar *) gmallocn (length, n); for (i = 0; i < length; i++) for (j = 0; j < n; j++) line[i * n + j] = lookup[in[i] * n + j]; @@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps2 = colorSpace2->getNComps(); lookup2 = indexedCS->getLookup(); colorSpace2->getDefaultRanges(x, y, indexHigh); - byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); + byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); for (k = 0; k < nComps2; ++k) { lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, sizeof(GfxColorComp)); @@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; @@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { switch (colorSpace->getMode()) { case csIndexed: case csSeparation: - tmp_line = (Guchar *) gmalloc (length * nComps2); + tmp_line = (Guchar *) gmallocn (length, nComps2); for (i = 0; i < length; i++) { for (j = 0; j < nComps2; j++) { tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];
CWE-189
null
null
905
JBIG2CodeTable::JBIG2CodeTable(Guint segNumA, JBIG2HuffmanTable *tableA): JBIG2Segment(segNumA) { table = tableA; }
DoS Exec Code Overflow
0
JBIG2CodeTable::JBIG2CodeTable(Guint segNumA, JBIG2HuffmanTable *tableA): JBIG2Segment(segNumA) { table = tableA; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
906
JBIG2MMRDecoder::JBIG2MMRDecoder() { str = NULL; reset(); }
DoS Exec Code Overflow
0
JBIG2MMRDecoder::JBIG2MMRDecoder() { str = NULL; reset(); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
907
JBIG2PatternDict::JBIG2PatternDict(Guint segNumA, Guint sizeA): JBIG2Segment(segNumA) { size = sizeA; bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *)); }
DoS Exec Code Overflow
0
JBIG2PatternDict::JBIG2PatternDict(Guint segNumA, Guint sizeA): JBIG2Segment(segNumA) { size = sizeA; bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *)); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
908
JBIG2Segment(Guint segNumA) { segNum = segNumA; }
DoS Exec Code Overflow
0
JBIG2Segment(Guint segNumA) { segNum = segNumA; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
909
JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA): FilterStream(strA) { pageBitmap = NULL; arithDecoder = new JArithmeticDecoder(); genericRegionStats = new JArithmeticDecoderStats(1 << 1); refinementRegionStats = new JArithmeticDecoderStats(1 << 1); iadhStats = new JArithmeticDecoderStats(1 << 9); iadwStats = new JArithmeticDecoderStats(1 << 9); iaexStats = new JArithmeticDecoderStats(1 << 9); iaaiStats = new JArithmeticDecoderStats(1 << 9); iadtStats = new JArithmeticDecoderStats(1 << 9); iaitStats = new JArithmeticDecoderStats(1 << 9); iafsStats = new JArithmeticDecoderStats(1 << 9); iadsStats = new JArithmeticDecoderStats(1 << 9); iardxStats = new JArithmeticDecoderStats(1 << 9); iardyStats = new JArithmeticDecoderStats(1 << 9); iardwStats = new JArithmeticDecoderStats(1 << 9); iardhStats = new JArithmeticDecoderStats(1 << 9); iariStats = new JArithmeticDecoderStats(1 << 9); iaidStats = new JArithmeticDecoderStats(1 << 1); huffDecoder = new JBIG2HuffmanDecoder(); mmrDecoder = new JBIG2MMRDecoder(); globalsStreamA->copy(&globalsStream); segments = globalSegments = NULL; curStr = NULL; dataPtr = dataEnd = NULL; }
DoS Exec Code Overflow
0
JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA): FilterStream(strA) { pageBitmap = NULL; arithDecoder = new JArithmeticDecoder(); genericRegionStats = new JArithmeticDecoderStats(1 << 1); refinementRegionStats = new JArithmeticDecoderStats(1 << 1); iadhStats = new JArithmeticDecoderStats(1 << 9); iadwStats = new JArithmeticDecoderStats(1 << 9); iaexStats = new JArithmeticDecoderStats(1 << 9); iaaiStats = new JArithmeticDecoderStats(1 << 9); iadtStats = new JArithmeticDecoderStats(1 << 9); iaitStats = new JArithmeticDecoderStats(1 << 9); iafsStats = new JArithmeticDecoderStats(1 << 9); iadsStats = new JArithmeticDecoderStats(1 << 9); iardxStats = new JArithmeticDecoderStats(1 << 9); iardyStats = new JArithmeticDecoderStats(1 << 9); iardwStats = new JArithmeticDecoderStats(1 << 9); iardhStats = new JArithmeticDecoderStats(1 << 9); iariStats = new JArithmeticDecoderStats(1 << 9); iaidStats = new JArithmeticDecoderStats(1 << 1); huffDecoder = new JBIG2HuffmanDecoder(); mmrDecoder = new JBIG2MMRDecoder(); globalsStreamA->copy(&globalsStream); segments = globalSegments = NULL; curStr = NULL; dataPtr = dataEnd = NULL; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
910
void JBIG2HuffmanDecoder::buildTable(JBIG2HuffmanTable *table, Guint len) { Guint i, j, k, prefix; JBIG2HuffmanTable tab; for (i = 0; i < len; ++i) { for (j = i; j < len && table[j].prefixLen == 0; ++j) ; if (j == len) { break; } for (k = j + 1; k < len; ++k) { if (table[k].prefixLen > 0 && table[k].prefixLen < table[j].prefixLen) { j = k; } } if (j != i) { tab = table[j]; for (k = j; k > i; --k) { table[k] = table[k - 1]; } table[i] = tab; } } table[i] = table[len]; i = 0; prefix = 0; table[i++].prefix = prefix++; for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) { prefix <<= table[i].prefixLen - table[i-1].prefixLen; table[i].prefix = prefix++; } }
DoS Exec Code Overflow
0
void JBIG2HuffmanDecoder::buildTable(JBIG2HuffmanTable *table, Guint len) { Guint i, j, k, prefix; JBIG2HuffmanTable tab; for (i = 0; i < len; ++i) { for (j = i; j < len && table[j].prefixLen == 0; ++j) ; if (j == len) { break; } for (k = j + 1; k < len; ++k) { if (table[k].prefixLen > 0 && table[k].prefixLen < table[j].prefixLen) { j = k; } } if (j != i) { tab = table[j]; for (k = j; k > i; --k) { table[k] = table[k - 1]; } table[i] = tab; } } table[i] = table[len]; i = 0; prefix = 0; table[i++].prefix = prefix++; for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) { prefix <<= table[i].prefixLen - table[i-1].prefixLen; table[i].prefix = prefix++; } }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
911
void clearPixel(int x, int y) { data[y * line + (x >> 3)] &= 0x7f7f >> (x & 7); }
DoS Exec Code Overflow
0
void clearPixel(int x, int y) { data[y * line + (x >> 3)] &= 0x7f7f >> (x & 7); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
912
void JBIG2Bitmap::clearToOne() { memset(data, 0xff, h * line); }
DoS Exec Code Overflow
0
void JBIG2Bitmap::clearToOne() { memset(data, 0xff, h * line); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
913
void JBIG2Bitmap::clearToZero() { memset(data, 0, h * line); }
DoS Exec Code Overflow
0
void JBIG2Bitmap::clearToZero() { memset(data, 0, h * line); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
914
void JBIG2Stream::close() { if (pageBitmap) { delete pageBitmap; pageBitmap = NULL; } if (segments) { deleteGooList(segments, JBIG2Segment); segments = NULL; } if (globalSegments) { deleteGooList(globalSegments, JBIG2Segment); globalSegments = NULL; } dataPtr = dataEnd = NULL; FilterStream::close(); }
DoS Exec Code Overflow
0
void JBIG2Stream::close() { if (pageBitmap) { delete pageBitmap; pageBitmap = NULL; } if (segments) { deleteGooList(segments, JBIG2Segment); segments = NULL; } if (globalSegments) { deleteGooList(globalSegments, JBIG2Segment); globalSegments = NULL; } dataPtr = dataEnd = NULL; FilterStream::close(); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
915
void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y, Guint combOp) { int x0, x1, y0, y1, xx, yy; Guchar *srcPtr, *destPtr; Guint src0, src1, src, dest, s1, s2, m1, m2, m3; GBool oneByte; if (y < 0) { y0 = -y; } else { y0 = 0; } if (y + bitmap->h > h) { y1 = h - y; } else { y1 = bitmap->h; } if (y0 >= y1) { return; } if (x >= 0) { x0 = x & ~7; } else { x0 = 0; } x1 = x + bitmap->w; if (x1 > w) { x1 = w; } if (x0 >= x1) { return; } s1 = x & 7; s2 = 8 - s1; m1 = 0xff >> (x1 & 7); m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); m3 = (0xff >> s1) & m2; oneByte = x0 == ((x1 - 1) & ~7); for (yy = y0; yy < y1; ++yy) { if (oneByte) { if (x >= 0) { destPtr = data + (y + yy) * line + (x >> 3); srcPtr = bitmap->data + yy * bitmap->line; dest = *destPtr; src1 = *srcPtr; switch (combOp) { case 0: // or dest |= (src1 >> s1) & m2; break; case 1: // and dest &= ((0xff00 | src1) >> s1) | m1; break; case 2: // xor dest ^= (src1 >> s1) & m2; break; case 3: // xnor dest ^= ((src1 ^ 0xff) >> s1) & m2; break; case 4: // replace dest = (dest & ~m3) | ((src1 >> s1) & m3); break; } *destPtr = dest; } else { destPtr = data + (y + yy) * line; srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); dest = *destPtr; src1 = *srcPtr; switch (combOp) { case 0: // or dest |= src1 & m2; break; case 1: // and dest &= src1 | m1; break; case 2: // xor dest ^= src1 & m2; break; case 3: // xnor dest ^= (src1 ^ 0xff) & m2; break; case 4: // replace dest = (src1 & m2) | (dest & m1); break; } *destPtr = dest; } } else { if (x >= 0) { destPtr = data + (y + yy) * line + (x >> 3); srcPtr = bitmap->data + yy * bitmap->line; src1 = *srcPtr++; dest = *destPtr; switch (combOp) { case 0: // or dest |= src1 >> s1; break; case 1: // and dest &= (0xff00 | src1) >> s1; break; case 2: // xor dest ^= src1 >> s1; break; case 3: // xnor dest ^= (src1 ^ 0xff) >> s1; break; case 4: // replace dest = (dest & (0xff << s2)) | (src1 >> s1); break; } *destPtr++ = dest; xx = x0 + 8; } else { destPtr = data + (y + yy) * line; srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); src1 = *srcPtr++; xx = x0; } for (; xx < x1 - 8; xx += 8) { dest = *destPtr; src0 = src1; src1 = *srcPtr++; src = (((src0 << 8) | src1) >> s1) & 0xff; switch (combOp) { case 0: // or dest |= src; break; case 1: // and dest &= src; break; case 2: // xor dest ^= src; break; case 3: // xnor dest ^= src ^ 0xff; break; case 4: // replace dest = src; break; } *destPtr++ = dest; } dest = *destPtr; src0 = src1; src1 = *srcPtr++; src = (((src0 << 8) | src1) >> s1) & 0xff; switch (combOp) { case 0: // or dest |= src & m2; break; case 1: // and dest &= src | m1; break; case 2: // xor dest ^= src & m2; break; case 3: // xnor dest ^= (src ^ 0xff) & m2; break; case 4: // replace dest = (src & m2) | (dest & m1); break; } *destPtr = dest; } } }
DoS Exec Code Overflow
0
void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y, Guint combOp) { int x0, x1, y0, y1, xx, yy; Guchar *srcPtr, *destPtr; Guint src0, src1, src, dest, s1, s2, m1, m2, m3; GBool oneByte; if (y < 0) { y0 = -y; } else { y0 = 0; } if (y + bitmap->h > h) { y1 = h - y; } else { y1 = bitmap->h; } if (y0 >= y1) { return; } if (x >= 0) { x0 = x & ~7; } else { x0 = 0; } x1 = x + bitmap->w; if (x1 > w) { x1 = w; } if (x0 >= x1) { return; } s1 = x & 7; s2 = 8 - s1; m1 = 0xff >> (x1 & 7); m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); m3 = (0xff >> s1) & m2; oneByte = x0 == ((x1 - 1) & ~7); for (yy = y0; yy < y1; ++yy) { if (oneByte) { if (x >= 0) { destPtr = data + (y + yy) * line + (x >> 3); srcPtr = bitmap->data + yy * bitmap->line; dest = *destPtr; src1 = *srcPtr; switch (combOp) { case 0: // or dest |= (src1 >> s1) & m2; break; case 1: // and dest &= ((0xff00 | src1) >> s1) | m1; break; case 2: // xor dest ^= (src1 >> s1) & m2; break; case 3: // xnor dest ^= ((src1 ^ 0xff) >> s1) & m2; break; case 4: // replace dest = (dest & ~m3) | ((src1 >> s1) & m3); break; } *destPtr = dest; } else { destPtr = data + (y + yy) * line; srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); dest = *destPtr; src1 = *srcPtr; switch (combOp) { case 0: // or dest |= src1 & m2; break; case 1: // and dest &= src1 | m1; break; case 2: // xor dest ^= src1 & m2; break; case 3: // xnor dest ^= (src1 ^ 0xff) & m2; break; case 4: // replace dest = (src1 & m2) | (dest & m1); break; } *destPtr = dest; } } else { if (x >= 0) { destPtr = data + (y + yy) * line + (x >> 3); srcPtr = bitmap->data + yy * bitmap->line; src1 = *srcPtr++; dest = *destPtr; switch (combOp) { case 0: // or dest |= src1 >> s1; break; case 1: // and dest &= (0xff00 | src1) >> s1; break; case 2: // xor dest ^= src1 >> s1; break; case 3: // xnor dest ^= (src1 ^ 0xff) >> s1; break; case 4: // replace dest = (dest & (0xff << s2)) | (src1 >> s1); break; } *destPtr++ = dest; xx = x0 + 8; } else { destPtr = data + (y + yy) * line; srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3); src1 = *srcPtr++; xx = x0; } for (; xx < x1 - 8; xx += 8) { dest = *destPtr; src0 = src1; src1 = *srcPtr++; src = (((src0 << 8) | src1) >> s1) & 0xff; switch (combOp) { case 0: // or dest |= src; break; case 1: // and dest &= src; break; case 2: // xor dest ^= src; break; case 3: // xnor dest ^= src ^ 0xff; break; case 4: // replace dest = src; break; } *destPtr++ = dest; } dest = *destPtr; src0 = src1; src1 = *srcPtr++; src = (((src0 << 8) | src1) >> s1) & 0xff; switch (combOp) { case 0: // or dest |= src & m2; break; case 1: // and dest &= src | m1; break; case 2: // xor dest ^= src & m2; break; case 3: // xnor dest ^= (src ^ 0xff) & m2; break; case 4: // replace dest = (src & m2) | (dest & m1); break; } *destPtr = dest; } } }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
916
JBIG2Bitmap *copy() { return new JBIG2Bitmap(0, this); }
DoS Exec Code Overflow
0
JBIG2Bitmap *copy() { return new JBIG2Bitmap(0, this); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
917
GBool JBIG2HuffmanDecoder::decodeInt(int *x, JBIG2HuffmanTable *table) { Guint i, len, prefix; i = 0; len = 0; prefix = 0; while (table[i].rangeLen != jbig2HuffmanEOT) { while (len < table[i].prefixLen) { prefix = (prefix << 1) | readBit(); ++len; } if (prefix == table[i].prefix) { if (table[i].rangeLen == jbig2HuffmanOOB) { return gFalse; } if (table[i].rangeLen == jbig2HuffmanLOW) { *x = table[i].val - readBits(32); } else if (table[i].rangeLen > 0) { *x = table[i].val + readBits(table[i].rangeLen); } else { *x = table[i].val; } return gTrue; } ++i; } return gFalse; }
DoS Exec Code Overflow
0
GBool JBIG2HuffmanDecoder::decodeInt(int *x, JBIG2HuffmanTable *table) { Guint i, len, prefix; i = 0; len = 0; prefix = 0; while (table[i].rangeLen != jbig2HuffmanEOT) { while (len < table[i].prefixLen) { prefix = (prefix << 1) | readBit(); ++len; } if (prefix == table[i].prefix) { if (table[i].rangeLen == jbig2HuffmanOOB) { return gFalse; } if (table[i].rangeLen == jbig2HuffmanLOW) { *x = table[i].val - readBits(32); } else if (table[i].rangeLen > 0) { *x = table[i].val + readBits(table[i].rangeLen); } else { *x = table[i].val; } return gTrue; } ++i; } return gFalse; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
918
void JBIG2Bitmap::duplicateRow(int yDest, int ySrc) { memcpy(data + yDest * line, data + ySrc * line, line); }
DoS Exec Code Overflow
0
void JBIG2Bitmap::duplicateRow(int yDest, int ySrc) { memcpy(data + yDest * line, data + ySrc * line, line); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
919
void JBIG2Bitmap::expand(int newH, Guint pixel) { if (newH <= h || line <= 0 || newH >= (INT_MAX - 1) / line) { error(-1, "invalid width/height"); gfree(data); data = NULL; return; } data = (Guchar *)grealloc(data, newH * line + 1); if (pixel) { memset(data + h * line, 0xff, (newH - h) * line); } else { memset(data + h * line, 0x00, (newH - h) * line); } h = newH; data[h * line] = 0; }
DoS Exec Code Overflow
0
void JBIG2Bitmap::expand(int newH, Guint pixel) { if (newH <= h || line <= 0 || newH >= (INT_MAX - 1) / line) { error(-1, "invalid width/height"); gfree(data); data = NULL; return; } data = (Guchar *)grealloc(data, newH * line + 1); if (pixel) { memset(data + h * line, 0xff, (newH - h) * line); } else { memset(data + h * line, 0x00, (newH - h) * line); } h = newH; data[h * line] = 0; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
920
JBIG2Segment *JBIG2Stream::findSegment(Guint segNum) { JBIG2Segment *seg; int i; for (i = 0; i < globalSegments->getLength(); ++i) { seg = (JBIG2Segment *)globalSegments->get(i); if (seg->getSegNum() == segNum) { return seg; } } for (i = 0; i < segments->getLength(); ++i) { seg = (JBIG2Segment *)segments->get(i); if (seg->getSegNum() == segNum) { return seg; } } return NULL; }
DoS Exec Code Overflow
0
JBIG2Segment *JBIG2Stream::findSegment(Guint segNum) { JBIG2Segment *seg; int i; for (i = 0; i < globalSegments->getLength(); ++i) { seg = (JBIG2Segment *)globalSegments->get(i); if (seg->getSegNum() == segNum) { return seg; } } for (i = 0; i < segments->getLength(); ++i) { seg = (JBIG2Segment *)segments->get(i); if (seg->getSegNum() == segNum) { return seg; } } return NULL; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
921
Guint JBIG2MMRDecoder::get24Bits() { while (bufLen < 24) { buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } return (buf >> (bufLen - 24)) & 0xffffff; }
DoS Exec Code Overflow
0
Guint JBIG2MMRDecoder::get24Bits() { while (bufLen < 24) { buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } return (buf >> (bufLen - 24)) & 0xffffff; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
922
int JBIG2MMRDecoder::get2DCode() { const CCITTCode *p; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; p = &twoDimTab1[(buf >> 1) & 0x7f]; } else if (bufLen == 8) { p = &twoDimTab1[(buf >> 1) & 0x7f]; } else { p = &twoDimTab1[(buf << (7 - bufLen)) & 0x7f]; if (p->bits < 0 || p->bits > (int)bufLen) { buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; p = &twoDimTab1[(buf >> (bufLen - 7)) & 0x7f]; } } if (p->bits < 0) { error(str->getPos(), "Bad two dim code in JBIG2 MMR stream"); return 0; } bufLen -= p->bits; return p->n; }
DoS Exec Code Overflow
0
int JBIG2MMRDecoder::get2DCode() { const CCITTCode *p; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; p = &twoDimTab1[(buf >> 1) & 0x7f]; } else if (bufLen == 8) { p = &twoDimTab1[(buf >> 1) & 0x7f]; } else { p = &twoDimTab1[(buf << (7 - bufLen)) & 0x7f]; if (p->bits < 0 || p->bits > (int)bufLen) { buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; p = &twoDimTab1[(buf >> (bufLen - 7)) & 0x7f]; } } if (p->bits < 0) { error(str->getPos(), "Bad two dim code in JBIG2 MMR stream"); return 0; } bufLen -= p->bits; return p->n; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
923
int JBIG2MMRDecoder::getBlackCode() { const CCITTCode *p; Guint code; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; } while (1) { if (bufLen >= 10 && ((buf >> (bufLen - 6)) & 0x3f) == 0) { if (bufLen <= 13) { code = buf << (13 - bufLen); } else { code = buf >> (bufLen - 13); } p = &blackTab1[code & 0x7f]; } else if (bufLen >= 7 && ((buf >> (bufLen - 4)) & 0x0f) == 0 && ((buf >> (bufLen - 6)) & 0x03) != 0) { if (bufLen <= 12) { code = buf << (12 - bufLen); } else { code = buf >> (bufLen - 12); } p = &blackTab2[(code & 0xff) - 64]; } else { if (bufLen <= 6) { code = buf << (6 - bufLen); } else { code = buf >> (bufLen - 6); } p = &blackTab3[code & 0x3f]; } if (p->bits > 0 && p->bits <= (int)bufLen) { bufLen -= p->bits; return p->n; } if (bufLen >= 13) { break; } buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } error(str->getPos(), "Bad black code in JBIG2 MMR stream"); --bufLen; return 1; }
DoS Exec Code Overflow
0
int JBIG2MMRDecoder::getBlackCode() { const CCITTCode *p; Guint code; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; } while (1) { if (bufLen >= 10 && ((buf >> (bufLen - 6)) & 0x3f) == 0) { if (bufLen <= 13) { code = buf << (13 - bufLen); } else { code = buf >> (bufLen - 13); } p = &blackTab1[code & 0x7f]; } else if (bufLen >= 7 && ((buf >> (bufLen - 4)) & 0x0f) == 0 && ((buf >> (bufLen - 6)) & 0x03) != 0) { if (bufLen <= 12) { code = buf << (12 - bufLen); } else { code = buf >> (bufLen - 12); } p = &blackTab2[(code & 0xff) - 64]; } else { if (bufLen <= 6) { code = buf << (6 - bufLen); } else { code = buf >> (bufLen - 6); } p = &blackTab3[code & 0x3f]; } if (p->bits > 0 && p->bits <= (int)bufLen) { bufLen -= p->bits; return p->n; } if (bufLen >= 13) { break; } buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } error(str->getPos(), "Bad black code in JBIG2 MMR stream"); --bufLen; return 1; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
924
int JBIG2Stream::getChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr++ ^ 0xff) & 0xff; } return EOF; }
DoS Exec Code Overflow
0
int JBIG2Stream::getChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr++ ^ 0xff) & 0xff; } return EOF; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
925
int getDataSize() { return h * line; }
DoS Exec Code Overflow
0
int getDataSize() { return h * line; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
926
JArithmeticDecoderStats *getGenericRegionStats() { return genericRegionStats; }
DoS Exec Code Overflow
0
JArithmeticDecoderStats *getGenericRegionStats() { return genericRegionStats; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
927
int getHeight() { return h; }
DoS Exec Code Overflow
0
int getHeight() { return h; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
928
JBIG2HuffmanTable *getHuffTable() { return table; }
DoS Exec Code Overflow
0
JBIG2HuffmanTable *getHuffTable() { return table; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
929
GooString *JBIG2Stream::getPSFilter(int psLevel, char *indent) { return NULL; }
DoS Exec Code Overflow
0
GooString *JBIG2Stream::getPSFilter(int psLevel, char *indent) { return NULL; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
930
JArithmeticDecoderStats *getRefinementRegionStats() { return refinementRegionStats; }
DoS Exec Code Overflow
0
JArithmeticDecoderStats *getRefinementRegionStats() { return refinementRegionStats; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
931
Guint getSegNum() { return segNum; }
DoS Exec Code Overflow
0
Guint getSegNum() { return segNum; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
932
Guint getSize() { return size; }
DoS Exec Code Overflow
0
Guint getSize() { return size; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
933
JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint x, Guint y, Guint wA, Guint hA) { JBIG2Bitmap *slice; Guint xx, yy; slice = new JBIG2Bitmap(0, wA, hA); slice->clearToZero(); for (yy = 0; yy < hA; ++yy) { for (xx = 0; xx < wA; ++xx) { if (getPixel(x + xx, y + yy)) { slice->setPixel(xx, yy); } } } return slice; }
DoS Exec Code Overflow
0
JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint x, Guint y, Guint wA, Guint hA) { JBIG2Bitmap *slice; Guint xx, yy; slice = new JBIG2Bitmap(0, wA, hA); slice->clearToZero(); for (yy = 0; yy < hA; ++yy) { for (xx = 0; xx < wA; ++xx) { if (getPixel(x + xx, y + yy)) { slice->setPixel(xx, yy); } } } return slice; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
934
virtual JBIG2SegmentType getType() { return jbig2SegBitmap; }
DoS Exec Code Overflow
0
virtual JBIG2SegmentType getType() { return jbig2SegBitmap; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
935
virtual JBIG2SegmentType getType() { return jbig2SegSymbolDict; }
DoS Exec Code Overflow
0
virtual JBIG2SegmentType getType() { return jbig2SegSymbolDict; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
936
virtual JBIG2SegmentType getType() { return jbig2SegPatternDict; }
DoS Exec Code Overflow
0
virtual JBIG2SegmentType getType() { return jbig2SegPatternDict; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
937
virtual JBIG2SegmentType getType() { return jbig2SegCodeTable; }
DoS Exec Code Overflow
0
virtual JBIG2SegmentType getType() { return jbig2SegCodeTable; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
938
int JBIG2MMRDecoder::getWhiteCode() { const CCITTCode *p; Guint code; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; } while (1) { if (bufLen >= 11 && ((buf >> (bufLen - 7)) & 0x7f) == 0) { if (bufLen <= 12) { code = buf << (12 - bufLen); } else { code = buf >> (bufLen - 12); } p = &whiteTab1[code & 0x1f]; } else { if (bufLen <= 9) { code = buf << (9 - bufLen); } else { code = buf >> (bufLen - 9); } p = &whiteTab2[code & 0x1ff]; } if (p->bits > 0 && p->bits <= (int)bufLen) { bufLen -= p->bits; return p->n; } if (bufLen >= 12) { break; } buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } error(str->getPos(), "Bad white code in JBIG2 MMR stream"); --bufLen; return 1; }
DoS Exec Code Overflow
0
int JBIG2MMRDecoder::getWhiteCode() { const CCITTCode *p; Guint code; if (bufLen == 0) { buf = str->getChar() & 0xff; bufLen = 8; ++nBytesRead; } while (1) { if (bufLen >= 11 && ((buf >> (bufLen - 7)) & 0x7f) == 0) { if (bufLen <= 12) { code = buf << (12 - bufLen); } else { code = buf >> (bufLen - 12); } p = &whiteTab1[code & 0x1f]; } else { if (bufLen <= 9) { code = buf << (9 - bufLen); } else { code = buf >> (bufLen - 9); } p = &whiteTab2[code & 0x1ff]; } if (p->bits > 0 && p->bits <= (int)bufLen) { bufLen -= p->bits; return p->n; } if (bufLen >= 12) { break; } buf = (buf << 8) | (str->getChar() & 0xff); bufLen += 8; ++nBytesRead; } error(str->getPos(), "Bad white code in JBIG2 MMR stream"); --bufLen; return 1; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
939
int getWidth() { return w; }
DoS Exec Code Overflow
0
int getWidth() { return w; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
940
GBool JBIG2Stream::isBinary(GBool last) { return str->isBinary(gTrue); }
DoS Exec Code Overflow
0
GBool JBIG2Stream::isBinary(GBool last) { return str->isBinary(gTrue); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
941
GBool isOk() { return data != NULL; }
DoS Exec Code Overflow
0
GBool isOk() { return data != NULL; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
942
int JBIG2Stream::lookChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr ^ 0xff) & 0xff; } return EOF; }
DoS Exec Code Overflow
0
int JBIG2Stream::lookChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr ^ 0xff) & 0xff; } return EOF; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
943
Guint JBIG2HuffmanDecoder::readBit() { if (bufLen == 0) { buf = str->getChar(); bufLen = 8; } --bufLen; return (buf >> bufLen) & 1; }
DoS Exec Code Overflow
0
Guint JBIG2HuffmanDecoder::readBit() { if (bufLen == 0) { buf = str->getChar(); bufLen = 8; } --bufLen; return (buf >> bufLen) & 1; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
944
Guint JBIG2HuffmanDecoder::readBits(Guint n) { Guint x, mask, nLeft; mask = (n == 32) ? 0xffffffff : ((1 << n) - 1); if (bufLen >= n) { x = (buf >> (bufLen - n)) & mask; bufLen -= n; } else { x = buf & ((1 << bufLen) - 1); nLeft = n - bufLen; bufLen = 0; while (nLeft >= 8) { x = (x << 8) | (str->getChar() & 0xff); nLeft -= 8; } if (nLeft > 0) { buf = str->getChar(); bufLen = 8 - nLeft; x = (x << nLeft) | ((buf >> bufLen) & ((1 << nLeft) - 1)); } } return x; }
DoS Exec Code Overflow
0
Guint JBIG2HuffmanDecoder::readBits(Guint n) { Guint x, mask, nLeft; mask = (n == 32) ? 0xffffffff : ((1 << n) - 1); if (bufLen >= n) { x = (buf >> (bufLen - n)) & mask; bufLen -= n; } else { x = buf & ((1 << bufLen) - 1); nLeft = n - bufLen; bufLen = 0; while (nLeft >= 8) { x = (x << 8) | (str->getChar() & 0xff); nLeft -= 8; } if (nLeft > 0) { buf = str->getChar(); bufLen = 8 - nLeft; x = (x << nLeft) | ((buf >> bufLen) & ((1 << nLeft) - 1)); } } return x; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
945
GBool JBIG2Stream::readByte(int *x) { int c0; if ((c0 = curStr->getChar()) == EOF) { return gFalse; } *x = c0; if (c0 & 0x80) { *x |= -1 - 0xff; } return gTrue; }
DoS Exec Code Overflow
0
GBool JBIG2Stream::readByte(int *x) { int c0; if ((c0 = curStr->getChar()) == EOF) { return gFalse; } *x = c0; if (c0 & 0x80) { *x |= -1 - 0xff; } return gTrue; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
946
void JBIG2Stream::readCodeTableSeg(Guint segNum, Guint length) { JBIG2HuffmanTable *huffTab; Guint flags, oob, prefixBits, rangeBits; int lowVal, highVal, val; Guint huffTabSize, i; if (!readUByte(&flags) || !readLong(&lowVal) || !readLong(&highVal)) { goto eofError; } oob = flags & 1; prefixBits = ((flags >> 1) & 7) + 1; rangeBits = ((flags >> 4) & 7) + 1; huffDecoder->reset(); huffTabSize = 8; huffTab = (JBIG2HuffmanTable *) gmallocn(huffTabSize, sizeof(JBIG2HuffmanTable)); i = 0; val = lowVal; while (val < highVal) { if (i == huffTabSize) { huffTabSize *= 2; huffTab = (JBIG2HuffmanTable *) greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable)); } huffTab[i].val = val; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = huffDecoder->readBits(rangeBits); val += 1 << huffTab[i].rangeLen; ++i; } if (i + oob + 3 > huffTabSize) { huffTabSize = i + oob + 3; huffTab = (JBIG2HuffmanTable *) greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable)); } huffTab[i].val = lowVal - 1; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = jbig2HuffmanLOW; ++i; huffTab[i].val = highVal; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = 32; ++i; if (oob) { huffTab[i].val = 0; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = jbig2HuffmanOOB; ++i; } huffTab[i].val = 0; huffTab[i].prefixLen = 0; huffTab[i].rangeLen = jbig2HuffmanEOT; huffDecoder->buildTable(huffTab, i); segments->append(new JBIG2CodeTable(segNum, huffTab)); return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
DoS Exec Code Overflow
0
void JBIG2Stream::readCodeTableSeg(Guint segNum, Guint length) { JBIG2HuffmanTable *huffTab; Guint flags, oob, prefixBits, rangeBits; int lowVal, highVal, val; Guint huffTabSize, i; if (!readUByte(&flags) || !readLong(&lowVal) || !readLong(&highVal)) { goto eofError; } oob = flags & 1; prefixBits = ((flags >> 1) & 7) + 1; rangeBits = ((flags >> 4) & 7) + 1; huffDecoder->reset(); huffTabSize = 8; huffTab = (JBIG2HuffmanTable *) gmallocn(huffTabSize, sizeof(JBIG2HuffmanTable)); i = 0; val = lowVal; while (val < highVal) { if (i == huffTabSize) { huffTabSize *= 2; huffTab = (JBIG2HuffmanTable *) greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable)); } huffTab[i].val = val; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = huffDecoder->readBits(rangeBits); val += 1 << huffTab[i].rangeLen; ++i; } if (i + oob + 3 > huffTabSize) { huffTabSize = i + oob + 3; huffTab = (JBIG2HuffmanTable *) greallocn(huffTab, huffTabSize, sizeof(JBIG2HuffmanTable)); } huffTab[i].val = lowVal - 1; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = jbig2HuffmanLOW; ++i; huffTab[i].val = highVal; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = 32; ++i; if (oob) { huffTab[i].val = 0; huffTab[i].prefixLen = huffDecoder->readBits(prefixBits); huffTab[i].rangeLen = jbig2HuffmanOOB; ++i; } huffTab[i].val = 0; huffTab[i].prefixLen = 0; huffTab[i].rangeLen = jbig2HuffmanEOT; huffDecoder->buildTable(huffTab, i); segments->append(new JBIG2CodeTable(segNum, huffTab)); return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
947
void JBIG2Stream::readEndOfStripeSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
DoS Exec Code Overflow
0
void JBIG2Stream::readEndOfStripeSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
948
void JBIG2Stream::readExtensionSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
DoS Exec Code Overflow
0
void JBIG2Stream::readExtensionSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
949
JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h, int templ, GBool tpgdOn, GBool useSkip, JBIG2Bitmap *skip, int *atx, int *aty, int mmrDataLength) { JBIG2Bitmap *bitmap; GBool ltp; Guint ltpCX, cx, cx0, cx1, cx2; JBIG2BitmapPtr cxPtr0 = {0}, cxPtr1 = {0}; JBIG2BitmapPtr atPtr0 = {0}, atPtr1 = {0}, atPtr2 = {0}, atPtr3 = {0}; int *refLine, *codingLine; int code1, code2, code3; int x, y, a0, pix, i, refI, codingI; bitmap = new JBIG2Bitmap(0, w, h); bitmap->clearToZero(); if (mmr) { mmrDecoder->reset(); refLine = (int *)gmallocn(w + 2, sizeof(int)); codingLine = (int *)gmallocn(w + 2, sizeof(int)); codingLine[0] = codingLine[1] = w; for (y = 0; y < h; ++y) { for (i = 0; codingLine[i] < w; ++i) { refLine[i] = codingLine[i]; } refLine[i] = refLine[i + 1] = w; refI = 0; // b1 = refLine[refI] codingI = 0; // a1 = codingLine[codingI] a0 = 0; do { code1 = mmrDecoder->get2DCode(); switch (code1) { case twoDimPass: if (refLine[refI] < w) { a0 = refLine[refI + 1]; refI += 2; } break; case twoDimHoriz: if (codingI & 1) { code1 = 0; do { code1 += code3 = mmrDecoder->getBlackCode(); } while (code3 >= 64); code2 = 0; do { code2 += code3 = mmrDecoder->getWhiteCode(); } while (code3 >= 64); } else { code1 = 0; do { code1 += code3 = mmrDecoder->getWhiteCode(); } while (code3 >= 64); code2 = 0; do { code2 += code3 = mmrDecoder->getBlackCode(); } while (code3 >= 64); } if (code1 > 0 || code2 > 0) { a0 = codingLine[codingI++] = a0 + code1; a0 = codingLine[codingI++] = a0 + code2; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVert0: a0 = codingLine[codingI++] = refLine[refI]; if (refLine[refI] < w) { ++refI; } break; case twoDimVertR1: a0 = codingLine[codingI++] = refLine[refI] + 1; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertR2: a0 = codingLine[codingI++] = refLine[refI] + 2; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertR3: a0 = codingLine[codingI++] = refLine[refI] + 3; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertL1: a0 = codingLine[codingI++] = refLine[refI] - 1; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; case twoDimVertL2: a0 = codingLine[codingI++] = refLine[refI] - 2; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; case twoDimVertL3: a0 = codingLine[codingI++] = refLine[refI] - 3; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; default: error(getPos(), "Illegal code in JBIG2 MMR bitmap data"); break; } } while (a0 < w); codingLine[codingI++] = w; i = 0; while (codingLine[i] < w) { for (x = codingLine[i]; x < codingLine[i+1]; ++x) { bitmap->setPixel(x, y); } i += 2; } } if (mmrDataLength >= 0) { mmrDecoder->skipTo(mmrDataLength); } else { if (mmrDecoder->get24Bits() != 0x001001) { error(getPos(), "Missing EOFB in JBIG2 MMR bitmap data"); } } gfree(refLine); gfree(codingLine); } else { ltpCX = 0; // make gcc happy if (tpgdOn) { switch (templ) { case 0: ltpCX = 0x3953; // 001 11001 0101 0011 break; case 1: ltpCX = 0x079a; // 0011 11001 101 0 break; case 2: ltpCX = 0x0e3; // 001 1100 01 1 break; case 3: ltpCX = 0x18a; // 01100 0101 1 break; } } ltp = 0; cx = cx0 = cx1 = cx2 = 0; // make gcc happy for (y = 0; y < h; ++y) { if (tpgdOn) { if (arithDecoder->decodeBit(ltpCX, genericRegionStats)) { ltp = !ltp; } if (ltp) { bitmap->duplicateRow(y, y-1); continue; } } switch (templ) { case 0: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); bitmap->getPixelPtr(atx[1], y + aty[1], &atPtr1); bitmap->getPixelPtr(atx[2], y + aty[2], &atPtr2); bitmap->getPixelPtr(atx[3], y + aty[3], &atPtr3); for (x = 0; x < w; ++x) { cx = (cx0 << 13) | (cx1 << 8) | (cx2 << 4) | (bitmap->nextPixel(&atPtr0) << 3) | (bitmap->nextPixel(&atPtr1) << 2) | (bitmap->nextPixel(&atPtr2) << 1) | bitmap->nextPixel(&atPtr3); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x07; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x0f; } break; case 1: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx0 << 9) | (cx1 << 4) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x0f; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x07; } break; case 2: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx0 << 7) | (cx1 << 3) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x07; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x0f; cx2 = ((cx2 << 1) | pix) & 0x03; } break; case 3: bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx1 << 5) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x0f; } break; } } } return bitmap; }
DoS Exec Code Overflow
0
JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h, int templ, GBool tpgdOn, GBool useSkip, JBIG2Bitmap *skip, int *atx, int *aty, int mmrDataLength) { JBIG2Bitmap *bitmap; GBool ltp; Guint ltpCX, cx, cx0, cx1, cx2; JBIG2BitmapPtr cxPtr0 = {0}, cxPtr1 = {0}; JBIG2BitmapPtr atPtr0 = {0}, atPtr1 = {0}, atPtr2 = {0}, atPtr3 = {0}; int *refLine, *codingLine; int code1, code2, code3; int x, y, a0, pix, i, refI, codingI; bitmap = new JBIG2Bitmap(0, w, h); bitmap->clearToZero(); if (mmr) { mmrDecoder->reset(); refLine = (int *)gmallocn(w + 2, sizeof(int)); codingLine = (int *)gmallocn(w + 2, sizeof(int)); codingLine[0] = codingLine[1] = w; for (y = 0; y < h; ++y) { for (i = 0; codingLine[i] < w; ++i) { refLine[i] = codingLine[i]; } refLine[i] = refLine[i + 1] = w; refI = 0; // b1 = refLine[refI] codingI = 0; // a1 = codingLine[codingI] a0 = 0; do { code1 = mmrDecoder->get2DCode(); switch (code1) { case twoDimPass: if (refLine[refI] < w) { a0 = refLine[refI + 1]; refI += 2; } break; case twoDimHoriz: if (codingI & 1) { code1 = 0; do { code1 += code3 = mmrDecoder->getBlackCode(); } while (code3 >= 64); code2 = 0; do { code2 += code3 = mmrDecoder->getWhiteCode(); } while (code3 >= 64); } else { code1 = 0; do { code1 += code3 = mmrDecoder->getWhiteCode(); } while (code3 >= 64); code2 = 0; do { code2 += code3 = mmrDecoder->getBlackCode(); } while (code3 >= 64); } if (code1 > 0 || code2 > 0) { a0 = codingLine[codingI++] = a0 + code1; a0 = codingLine[codingI++] = a0 + code2; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVert0: a0 = codingLine[codingI++] = refLine[refI]; if (refLine[refI] < w) { ++refI; } break; case twoDimVertR1: a0 = codingLine[codingI++] = refLine[refI] + 1; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertR2: a0 = codingLine[codingI++] = refLine[refI] + 2; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertR3: a0 = codingLine[codingI++] = refLine[refI] + 3; if (refLine[refI] < w) { ++refI; while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } } break; case twoDimVertL1: a0 = codingLine[codingI++] = refLine[refI] - 1; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; case twoDimVertL2: a0 = codingLine[codingI++] = refLine[refI] - 2; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; case twoDimVertL3: a0 = codingLine[codingI++] = refLine[refI] - 3; if (refI > 0) { --refI; } else { ++refI; } while (refLine[refI] <= a0 && refLine[refI] < w) { refI += 2; } break; default: error(getPos(), "Illegal code in JBIG2 MMR bitmap data"); break; } } while (a0 < w); codingLine[codingI++] = w; i = 0; while (codingLine[i] < w) { for (x = codingLine[i]; x < codingLine[i+1]; ++x) { bitmap->setPixel(x, y); } i += 2; } } if (mmrDataLength >= 0) { mmrDecoder->skipTo(mmrDataLength); } else { if (mmrDecoder->get24Bits() != 0x001001) { error(getPos(), "Missing EOFB in JBIG2 MMR bitmap data"); } } gfree(refLine); gfree(codingLine); } else { ltpCX = 0; // make gcc happy if (tpgdOn) { switch (templ) { case 0: ltpCX = 0x3953; // 001 11001 0101 0011 break; case 1: ltpCX = 0x079a; // 0011 11001 101 0 break; case 2: ltpCX = 0x0e3; // 001 1100 01 1 break; case 3: ltpCX = 0x18a; // 01100 0101 1 break; } } ltp = 0; cx = cx0 = cx1 = cx2 = 0; // make gcc happy for (y = 0; y < h; ++y) { if (tpgdOn) { if (arithDecoder->decodeBit(ltpCX, genericRegionStats)) { ltp = !ltp; } if (ltp) { bitmap->duplicateRow(y, y-1); continue; } } switch (templ) { case 0: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); bitmap->getPixelPtr(atx[1], y + aty[1], &atPtr1); bitmap->getPixelPtr(atx[2], y + aty[2], &atPtr2); bitmap->getPixelPtr(atx[3], y + aty[3], &atPtr3); for (x = 0; x < w; ++x) { cx = (cx0 << 13) | (cx1 << 8) | (cx2 << 4) | (bitmap->nextPixel(&atPtr0) << 3) | (bitmap->nextPixel(&atPtr1) << 2) | (bitmap->nextPixel(&atPtr2) << 1) | bitmap->nextPixel(&atPtr3); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x07; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x0f; } break; case 1: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx0 << 9) | (cx1 << 4) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x0f; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x07; } break; case 2: bitmap->getPixelPtr(0, y-2, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); cx0 = (cx0 << 1) | bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx0 << 7) | (cx1 << 3) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 0x07; cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x0f; cx2 = ((cx2 << 1) | pix) & 0x03; } break; case 3: bitmap->getPixelPtr(0, y-1, &cxPtr1); cx1 = bitmap->nextPixel(&cxPtr1); cx1 = (cx1 << 1) | bitmap->nextPixel(&cxPtr1); cx2 = 0; bitmap->getPixelPtr(atx[0], y + aty[0], &atPtr0); for (x = 0; x < w; ++x) { cx = (cx1 << 5) | (cx2 << 1) | bitmap->nextPixel(&atPtr0); if (useSkip && skip->getPixel(x, y)) { pix = 0; } else if ((pix = arithDecoder->decodeBit(cx, genericRegionStats))) { bitmap->setPixel(x, y); } cx1 = ((cx1 << 1) | bitmap->nextPixel(&cxPtr1)) & 0x1f; cx2 = ((cx2 << 1) | pix) & 0x0f; } break; } } } return bitmap; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
950
JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h, int templ, GBool tpgrOn, JBIG2Bitmap *refBitmap, int refDX, int refDY, int *atx, int *aty) { JBIG2Bitmap *bitmap; GBool ltp; Guint ltpCX, cx, cx0, cx2, cx3, cx4, tpgrCX0, tpgrCX1, tpgrCX2; JBIG2BitmapPtr cxPtr0 = {0}; JBIG2BitmapPtr cxPtr1 = {0}; JBIG2BitmapPtr cxPtr2 = {0}; JBIG2BitmapPtr cxPtr3 = {0}; JBIG2BitmapPtr cxPtr4 = {0}; JBIG2BitmapPtr cxPtr5 = {0}; JBIG2BitmapPtr cxPtr6 = {0}; JBIG2BitmapPtr tpgrCXPtr0 = {0}; JBIG2BitmapPtr tpgrCXPtr1 = {0}; JBIG2BitmapPtr tpgrCXPtr2 = {0}; int x, y, pix; bitmap = new JBIG2Bitmap(0, w, h); if (!bitmap->isOk()) { delete bitmap; return NULL; } bitmap->clearToZero(); if (templ) { ltpCX = 0x008; } else { ltpCX = 0x0010; } ltp = 0; for (y = 0; y < h; ++y) { if (templ) { bitmap->getPixelPtr(0, y-1, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(-1, y, &cxPtr1); refBitmap->getPixelPtr(-refDX, y-1-refDY, &cxPtr2); refBitmap->getPixelPtr(-1-refDX, y-refDY, &cxPtr3); cx3 = refBitmap->nextPixel(&cxPtr3); cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3); refBitmap->getPixelPtr(-refDX, y+1-refDY, &cxPtr4); cx4 = refBitmap->nextPixel(&cxPtr4); tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; // make gcc happy if (tpgrOn) { refBitmap->getPixelPtr(-1-refDX, y-1-refDY, &tpgrCXPtr0); tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); refBitmap->getPixelPtr(-1-refDX, y-refDY, &tpgrCXPtr1); tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &tpgrCXPtr2); tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); } for (x = 0; x < w; ++x) { cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 7; cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7; cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 3; if (tpgrOn) { tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7; tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7; tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7; if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) { ltp = !ltp; } if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) { bitmap->clearPixel(x, y); continue; } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) { bitmap->setPixel(x, y); continue; } } cx = (cx0 << 7) | (bitmap->nextPixel(&cxPtr1) << 6) | (refBitmap->nextPixel(&cxPtr2) << 5) | (cx3 << 2) | cx4; if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) { bitmap->setPixel(x, y); } } } else { bitmap->getPixelPtr(0, y-1, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(-1, y, &cxPtr1); refBitmap->getPixelPtr(-refDX, y-1-refDY, &cxPtr2); cx2 = refBitmap->nextPixel(&cxPtr2); refBitmap->getPixelPtr(-1-refDX, y-refDY, &cxPtr3); cx3 = refBitmap->nextPixel(&cxPtr3); cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &cxPtr4); cx4 = refBitmap->nextPixel(&cxPtr4); cx4 = (cx4 << 1) | refBitmap->nextPixel(&cxPtr4); bitmap->getPixelPtr(atx[0], y+aty[0], &cxPtr5); refBitmap->getPixelPtr(atx[1]-refDX, y+aty[1]-refDY, &cxPtr6); tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; // make gcc happy if (tpgrOn) { refBitmap->getPixelPtr(-1-refDX, y-1-refDY, &tpgrCXPtr0); tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); refBitmap->getPixelPtr(-1-refDX, y-refDY, &tpgrCXPtr1); tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &tpgrCXPtr2); tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); } for (x = 0; x < w; ++x) { cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 3; cx2 = ((cx2 << 1) | refBitmap->nextPixel(&cxPtr2)) & 3; cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7; cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 7; if (tpgrOn) { tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7; tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7; tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7; if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) { ltp = !ltp; } if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) { bitmap->clearPixel(x, y); continue; } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) { bitmap->setPixel(x, y); continue; } } cx = (cx0 << 11) | (bitmap->nextPixel(&cxPtr1) << 10) | (cx2 << 8) | (cx3 << 5) | (cx4 << 2) | (bitmap->nextPixel(&cxPtr5) << 1) | refBitmap->nextPixel(&cxPtr6); if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) { bitmap->setPixel(x, y); } } } } return bitmap; }
DoS Exec Code Overflow
0
JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h, int templ, GBool tpgrOn, JBIG2Bitmap *refBitmap, int refDX, int refDY, int *atx, int *aty) { JBIG2Bitmap *bitmap; GBool ltp; Guint ltpCX, cx, cx0, cx2, cx3, cx4, tpgrCX0, tpgrCX1, tpgrCX2; JBIG2BitmapPtr cxPtr0 = {0}; JBIG2BitmapPtr cxPtr1 = {0}; JBIG2BitmapPtr cxPtr2 = {0}; JBIG2BitmapPtr cxPtr3 = {0}; JBIG2BitmapPtr cxPtr4 = {0}; JBIG2BitmapPtr cxPtr5 = {0}; JBIG2BitmapPtr cxPtr6 = {0}; JBIG2BitmapPtr tpgrCXPtr0 = {0}; JBIG2BitmapPtr tpgrCXPtr1 = {0}; JBIG2BitmapPtr tpgrCXPtr2 = {0}; int x, y, pix; bitmap = new JBIG2Bitmap(0, w, h); if (!bitmap->isOk()) { delete bitmap; return NULL; } bitmap->clearToZero(); if (templ) { ltpCX = 0x008; } else { ltpCX = 0x0010; } ltp = 0; for (y = 0; y < h; ++y) { if (templ) { bitmap->getPixelPtr(0, y-1, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(-1, y, &cxPtr1); refBitmap->getPixelPtr(-refDX, y-1-refDY, &cxPtr2); refBitmap->getPixelPtr(-1-refDX, y-refDY, &cxPtr3); cx3 = refBitmap->nextPixel(&cxPtr3); cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3); refBitmap->getPixelPtr(-refDX, y+1-refDY, &cxPtr4); cx4 = refBitmap->nextPixel(&cxPtr4); tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; // make gcc happy if (tpgrOn) { refBitmap->getPixelPtr(-1-refDX, y-1-refDY, &tpgrCXPtr0); tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); refBitmap->getPixelPtr(-1-refDX, y-refDY, &tpgrCXPtr1); tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &tpgrCXPtr2); tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); } for (x = 0; x < w; ++x) { cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 7; cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7; cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 3; if (tpgrOn) { tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7; tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7; tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7; if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) { ltp = !ltp; } if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) { bitmap->clearPixel(x, y); continue; } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) { bitmap->setPixel(x, y); continue; } } cx = (cx0 << 7) | (bitmap->nextPixel(&cxPtr1) << 6) | (refBitmap->nextPixel(&cxPtr2) << 5) | (cx3 << 2) | cx4; if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) { bitmap->setPixel(x, y); } } } else { bitmap->getPixelPtr(0, y-1, &cxPtr0); cx0 = bitmap->nextPixel(&cxPtr0); bitmap->getPixelPtr(-1, y, &cxPtr1); refBitmap->getPixelPtr(-refDX, y-1-refDY, &cxPtr2); cx2 = refBitmap->nextPixel(&cxPtr2); refBitmap->getPixelPtr(-1-refDX, y-refDY, &cxPtr3); cx3 = refBitmap->nextPixel(&cxPtr3); cx3 = (cx3 << 1) | refBitmap->nextPixel(&cxPtr3); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &cxPtr4); cx4 = refBitmap->nextPixel(&cxPtr4); cx4 = (cx4 << 1) | refBitmap->nextPixel(&cxPtr4); bitmap->getPixelPtr(atx[0], y+aty[0], &cxPtr5); refBitmap->getPixelPtr(atx[1]-refDX, y+aty[1]-refDY, &cxPtr6); tpgrCX0 = tpgrCX1 = tpgrCX2 = 0; // make gcc happy if (tpgrOn) { refBitmap->getPixelPtr(-1-refDX, y-1-refDY, &tpgrCXPtr0); tpgrCX0 = refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); tpgrCX0 = (tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0); refBitmap->getPixelPtr(-1-refDX, y-refDY, &tpgrCXPtr1); tpgrCX1 = refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); tpgrCX1 = (tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1); refBitmap->getPixelPtr(-1-refDX, y+1-refDY, &tpgrCXPtr2); tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2); } for (x = 0; x < w; ++x) { cx0 = ((cx0 << 1) | bitmap->nextPixel(&cxPtr0)) & 3; cx2 = ((cx2 << 1) | refBitmap->nextPixel(&cxPtr2)) & 3; cx3 = ((cx3 << 1) | refBitmap->nextPixel(&cxPtr3)) & 7; cx4 = ((cx4 << 1) | refBitmap->nextPixel(&cxPtr4)) & 7; if (tpgrOn) { tpgrCX0 = ((tpgrCX0 << 1) | refBitmap->nextPixel(&tpgrCXPtr0)) & 7; tpgrCX1 = ((tpgrCX1 << 1) | refBitmap->nextPixel(&tpgrCXPtr1)) & 7; tpgrCX2 = ((tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2)) & 7; if (arithDecoder->decodeBit(ltpCX, refinementRegionStats)) { ltp = !ltp; } if (tpgrCX0 == 0 && tpgrCX1 == 0 && tpgrCX2 == 0) { bitmap->clearPixel(x, y); continue; } else if (tpgrCX0 == 7 && tpgrCX1 == 7 && tpgrCX2 == 7) { bitmap->setPixel(x, y); continue; } } cx = (cx0 << 11) | (bitmap->nextPixel(&cxPtr1) << 10) | (cx2 << 8) | (cx3 << 5) | (cx4 << 2) | (bitmap->nextPixel(&cxPtr5) << 1) | refBitmap->nextPixel(&cxPtr6); if ((pix = arithDecoder->decodeBit(cx, refinementRegionStats))) { bitmap->setPixel(x, y); } } } } return bitmap; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
951
void JBIG2Stream::readGenericRefinementRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length, Guint *refSegs, Guint nRefSegs) { JBIG2Bitmap *bitmap, *refBitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, templ, tpgrOn; int atx[2], aty[2]; JBIG2Segment *seg; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } templ = flags & 1; tpgrOn = (flags >> 1) & 1; if (!templ) { if (!readByte(&atx[0]) || !readByte(&aty[0]) || !readByte(&atx[1]) || !readByte(&aty[1])) { goto eofError; } } if (nRefSegs == 0 || imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } } if (nRefSegs > 1) { error(getPos(), "Bad reference in JBIG2 generic refinement segment"); return; } if (nRefSegs == 1) { seg = findSegment(refSegs[0]); if (seg == NULL || seg->getType() != jbig2SegBitmap) { error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment"); return; } refBitmap = (JBIG2Bitmap *)seg; } else { refBitmap = pageBitmap->getSlice(x, y, w, h); } resetRefinementStats(templ, NULL); arithDecoder->start(); bitmap = readGenericRefinementRegion(w, h, templ, tpgrOn, refBitmap, 0, 0, atx, aty); if (imm) { pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { bitmap->setSegNum(segNum); segments->append(bitmap); } if (nRefSegs == 1) { discardSegment(refSegs[0]); } else { delete refBitmap; } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
DoS Exec Code Overflow
0
void JBIG2Stream::readGenericRefinementRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length, Guint *refSegs, Guint nRefSegs) { JBIG2Bitmap *bitmap, *refBitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, templ, tpgrOn; int atx[2], aty[2]; JBIG2Segment *seg; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } templ = flags & 1; tpgrOn = (flags >> 1) & 1; if (!templ) { if (!readByte(&atx[0]) || !readByte(&aty[0]) || !readByte(&atx[1]) || !readByte(&aty[1])) { goto eofError; } } if (nRefSegs == 0 || imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } } if (nRefSegs > 1) { error(getPos(), "Bad reference in JBIG2 generic refinement segment"); return; } if (nRefSegs == 1) { seg = findSegment(refSegs[0]); if (seg == NULL || seg->getType() != jbig2SegBitmap) { error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment"); return; } refBitmap = (JBIG2Bitmap *)seg; } else { refBitmap = pageBitmap->getSlice(x, y, w, h); } resetRefinementStats(templ, NULL); arithDecoder->start(); bitmap = readGenericRefinementRegion(w, h, templ, tpgrOn, refBitmap, 0, 0, atx, aty); if (imm) { pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { bitmap->setSegNum(segNum); segments->append(bitmap); } if (nRefSegs == 1) { discardSegment(refSegs[0]); } else { delete refBitmap; } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
952
void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length) { JBIG2Bitmap *bitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, mmr, templ, tpgdOn; int atx[4], aty[4]; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } mmr = flags & 1; templ = (flags >> 1) & 3; tpgdOn = (flags >> 3) & 1; if (!mmr) { if (templ == 0) { if (!readByte(&atx[0]) || !readByte(&aty[0]) || !readByte(&atx[1]) || !readByte(&aty[1]) || !readByte(&atx[2]) || !readByte(&aty[2]) || !readByte(&atx[3]) || !readByte(&aty[3])) { goto eofError; } } else { if (!readByte(&atx[0]) || !readByte(&aty[0])) { goto eofError; } } } if (!mmr) { resetGenericStats(templ, NULL); arithDecoder->start(); } bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse, NULL, atx, aty, mmr ? 0 : length - 18); if (imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { bitmap->setSegNum(segNum); segments->append(bitmap); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
DoS Exec Code Overflow
0
void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length) { JBIG2Bitmap *bitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, mmr, templ, tpgdOn; int atx[4], aty[4]; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } mmr = flags & 1; templ = (flags >> 1) & 3; tpgdOn = (flags >> 3) & 1; if (!mmr) { if (templ == 0) { if (!readByte(&atx[0]) || !readByte(&aty[0]) || !readByte(&atx[1]) || !readByte(&aty[1]) || !readByte(&atx[2]) || !readByte(&aty[2]) || !readByte(&atx[3]) || !readByte(&aty[3])) { goto eofError; } } else { if (!readByte(&atx[0]) || !readByte(&aty[0])) { goto eofError; } } } if (!mmr) { resetGenericStats(templ, NULL); arithDecoder->start(); } bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse, NULL, atx, aty, mmr ? 0 : length - 18); if (imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { bitmap->setSegNum(segNum); segments->append(bitmap); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
953
void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length, Guint *refSegs, Guint nRefSegs) { JBIG2Bitmap *bitmap; JBIG2Segment *seg; JBIG2PatternDict *patternDict; JBIG2Bitmap *skipBitmap; Guint *grayImg; JBIG2Bitmap *grayBitmap; JBIG2Bitmap *patternBitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, mmr, templ, enableSkip, combOp; Guint gridW, gridH, stepX, stepY, patW, patH; int atx[4], aty[4]; int gridX, gridY, xx, yy, bit, j; Guint bpp, m, n, i; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } mmr = flags & 1; templ = (flags >> 1) & 3; enableSkip = (flags >> 3) & 1; combOp = (flags >> 4) & 7; if (!readULong(&gridW) || !readULong(&gridH) || !readLong(&gridX) || !readLong(&gridY) || !readUWord(&stepX) || !readUWord(&stepY)) { goto eofError; } if (w == 0 || h == 0 || w >= INT_MAX / h) { error(getPos(), "Bad bitmap size in JBIG2 halftone segment"); return; } if (gridH == 0 || gridW >= INT_MAX / gridH) { error(getPos(), "Bad grid size in JBIG2 halftone segment"); return; } if (nRefSegs != 1) { error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); return; } seg = findSegment(refSegs[0]); if (seg == NULL || seg->getType() != jbig2SegPatternDict) { error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); return; } patternDict = (JBIG2PatternDict *)seg; bpp = 0; i = 1; while (i < patternDict->getSize()) { ++bpp; i <<= 1; } patW = patternDict->getBitmap(0)->getWidth(); patH = patternDict->getBitmap(0)->getHeight(); if (!mmr) { resetGenericStats(templ, NULL); arithDecoder->start(); } bitmap = new JBIG2Bitmap(segNum, w, h); if (flags & 0x80) { // HDEFPIXEL bitmap->clearToOne(); } else { bitmap->clearToZero(); } skipBitmap = NULL; if (enableSkip) { skipBitmap = new JBIG2Bitmap(0, gridW, gridH); skipBitmap->clearToZero(); for (m = 0; m < gridH; ++m) { for (n = 0; n < gridW; ++n) { xx = gridX + m * stepY + n * stepX; yy = gridY + m * stepX - n * stepY; if (((xx + (int)patW) >> 8) <= 0 || (xx >> 8) >= (int)w || ((yy + (int)patH) >> 8) <= 0 || (yy >> 8) >= (int)h) { skipBitmap->setPixel(n, m); } } } } grayImg = (Guint *)gmallocn(gridW * gridH, sizeof(Guint)); memset(grayImg, 0, gridW * gridH * sizeof(Guint)); atx[0] = templ <= 1 ? 3 : 2; aty[0] = -1; atx[1] = -3; aty[1] = -1; atx[2] = 2; aty[2] = -2; atx[3] = -2; aty[3] = -2; for (j = bpp - 1; j >= 0; --j) { grayBitmap = readGenericBitmap(mmr, gridW, gridH, templ, gFalse, enableSkip, skipBitmap, atx, aty, -1); i = 0; for (m = 0; m < gridH; ++m) { for (n = 0; n < gridW; ++n) { bit = grayBitmap->getPixel(n, m) ^ (grayImg[i] & 1); grayImg[i] = (grayImg[i] << 1) | bit; ++i; } } delete grayBitmap; } i = 0; for (m = 0; m < gridH; ++m) { xx = gridX + m * stepY; yy = gridY + m * stepX; for (n = 0; n < gridW; ++n) { if (!(enableSkip && skipBitmap->getPixel(n, m))) { patternBitmap = patternDict->getBitmap(grayImg[i]); bitmap->combine(patternBitmap, xx >> 8, yy >> 8, combOp); } xx += stepX; yy -= stepY; ++i; } } gfree(grayImg); if (skipBitmap) { delete skipBitmap; } if (imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { segments->append(bitmap); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
DoS Exec Code Overflow
0
void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm, GBool lossless, Guint length, Guint *refSegs, Guint nRefSegs) { JBIG2Bitmap *bitmap; JBIG2Segment *seg; JBIG2PatternDict *patternDict; JBIG2Bitmap *skipBitmap; Guint *grayImg; JBIG2Bitmap *grayBitmap; JBIG2Bitmap *patternBitmap; Guint w, h, x, y, segInfoFlags, extCombOp; Guint flags, mmr, templ, enableSkip, combOp; Guint gridW, gridH, stepX, stepY, patW, patH; int atx[4], aty[4]; int gridX, gridY, xx, yy, bit, j; Guint bpp, m, n, i; if (!readULong(&w) || !readULong(&h) || !readULong(&x) || !readULong(&y) || !readUByte(&segInfoFlags)) { goto eofError; } extCombOp = segInfoFlags & 7; if (!readUByte(&flags)) { goto eofError; } mmr = flags & 1; templ = (flags >> 1) & 3; enableSkip = (flags >> 3) & 1; combOp = (flags >> 4) & 7; if (!readULong(&gridW) || !readULong(&gridH) || !readLong(&gridX) || !readLong(&gridY) || !readUWord(&stepX) || !readUWord(&stepY)) { goto eofError; } if (w == 0 || h == 0 || w >= INT_MAX / h) { error(getPos(), "Bad bitmap size in JBIG2 halftone segment"); return; } if (gridH == 0 || gridW >= INT_MAX / gridH) { error(getPos(), "Bad grid size in JBIG2 halftone segment"); return; } if (nRefSegs != 1) { error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); return; } seg = findSegment(refSegs[0]); if (seg == NULL || seg->getType() != jbig2SegPatternDict) { error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); return; } patternDict = (JBIG2PatternDict *)seg; bpp = 0; i = 1; while (i < patternDict->getSize()) { ++bpp; i <<= 1; } patW = patternDict->getBitmap(0)->getWidth(); patH = patternDict->getBitmap(0)->getHeight(); if (!mmr) { resetGenericStats(templ, NULL); arithDecoder->start(); } bitmap = new JBIG2Bitmap(segNum, w, h); if (flags & 0x80) { // HDEFPIXEL bitmap->clearToOne(); } else { bitmap->clearToZero(); } skipBitmap = NULL; if (enableSkip) { skipBitmap = new JBIG2Bitmap(0, gridW, gridH); skipBitmap->clearToZero(); for (m = 0; m < gridH; ++m) { for (n = 0; n < gridW; ++n) { xx = gridX + m * stepY + n * stepX; yy = gridY + m * stepX - n * stepY; if (((xx + (int)patW) >> 8) <= 0 || (xx >> 8) >= (int)w || ((yy + (int)patH) >> 8) <= 0 || (yy >> 8) >= (int)h) { skipBitmap->setPixel(n, m); } } } } grayImg = (Guint *)gmallocn(gridW * gridH, sizeof(Guint)); memset(grayImg, 0, gridW * gridH * sizeof(Guint)); atx[0] = templ <= 1 ? 3 : 2; aty[0] = -1; atx[1] = -3; aty[1] = -1; atx[2] = 2; aty[2] = -2; atx[3] = -2; aty[3] = -2; for (j = bpp - 1; j >= 0; --j) { grayBitmap = readGenericBitmap(mmr, gridW, gridH, templ, gFalse, enableSkip, skipBitmap, atx, aty, -1); i = 0; for (m = 0; m < gridH; ++m) { for (n = 0; n < gridW; ++n) { bit = grayBitmap->getPixel(n, m) ^ (grayImg[i] & 1); grayImg[i] = (grayImg[i] << 1) | bit; ++i; } } delete grayBitmap; } i = 0; for (m = 0; m < gridH; ++m) { xx = gridX + m * stepY; yy = gridY + m * stepX; for (n = 0; n < gridW; ++n) { if (!(enableSkip && skipBitmap->getPixel(n, m))) { patternBitmap = patternDict->getBitmap(grayImg[i]); bitmap->combine(patternBitmap, xx >> 8, yy >> 8, combOp); } xx += stepX; yy -= stepY; ++i; } } gfree(grayImg); if (skipBitmap) { delete skipBitmap; } if (imm) { if (pageH == 0xffffffff && y + h > curPageH) { pageBitmap->expand(y + h, pageDefPixel); } pageBitmap->combine(bitmap, x, y, extCombOp); delete bitmap; } else { segments->append(bitmap); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
954
GBool JBIG2Stream::readLong(int *x) { int c0, c1, c2, c3; if ((c0 = curStr->getChar()) == EOF || (c1 = curStr->getChar()) == EOF || (c2 = curStr->getChar()) == EOF || (c3 = curStr->getChar()) == EOF) { return gFalse; } *x = ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3); if (c0 & 0x80) { *x |= -1 - (int)0xffffffff; } return gTrue; }
DoS Exec Code Overflow
0
GBool JBIG2Stream::readLong(int *x) { int c0, c1, c2, c3; if ((c0 = curStr->getChar()) == EOF || (c1 = curStr->getChar()) == EOF || (c2 = curStr->getChar()) == EOF || (c3 = curStr->getChar()) == EOF) { return gFalse; } *x = ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3); if (c0 & 0x80) { *x |= -1 - (int)0xffffffff; } return gTrue; }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
955
void JBIG2Stream::readPageInfoSeg(Guint length) { Guint xRes, yRes, flags, striping; if (!readULong(&pageW) || !readULong(&pageH) || !readULong(&xRes) || !readULong(&yRes) || !readUByte(&flags) || !readUWord(&striping)) { goto eofError; } pageDefPixel = (flags >> 2) & 1; defCombOp = (flags >> 3) & 3; if (pageH == 0xffffffff) { curPageH = striping & 0x7fff; } else { curPageH = pageH; } pageBitmap = new JBIG2Bitmap(0, pageW, curPageH); if (pageDefPixel) { pageBitmap->clearToOne(); } else { pageBitmap->clearToZero(); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
DoS Exec Code Overflow
0
void JBIG2Stream::readPageInfoSeg(Guint length) { Guint xRes, yRes, flags, striping; if (!readULong(&pageW) || !readULong(&pageH) || !readULong(&xRes) || !readULong(&yRes) || !readUByte(&flags) || !readUWord(&striping)) { goto eofError; } pageDefPixel = (flags >> 2) & 1; defCombOp = (flags >> 3) & 3; if (pageH == 0xffffffff) { curPageH = striping & 0x7fff; } else { curPageH = pageH; } pageBitmap = new JBIG2Bitmap(0, pageW, curPageH); if (pageDefPixel) { pageBitmap->clearToOne(); } else { pageBitmap->clearToZero(); } return; eofError: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
956
void JBIG2Stream::readProfilesSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
DoS Exec Code Overflow
0
void JBIG2Stream::readProfilesSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); data[h * line] = 0; } @@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): return; } // need to allocate one extra guard byte for use in combine() - data = (Guchar *)gmalloc(h * line + 1); + data = (Guchar *)gmallocn(h, line + 1); memcpy(data, bitmap->data, h * line); data[h * line] = 0; }
CWE-189
null
null
957
DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA, GfxImageColorMap *colorMapA): FilterStream(strA) { width = widthA; height = heightA; colorMap = colorMapA; imgStr = NULL; pixelIdx = 0; bufIdx = gfxColorMaxComps; bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> getAlt()->getNComps(); func = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> getTintTransformFunc(); }
DoS Exec Code Overflow
0
DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA, GfxImageColorMap *colorMapA): FilterStream(strA) { width = widthA; height = heightA; colorMap = colorMapA; imgStr = NULL; pixelIdx = 0; bufIdx = gfxColorMaxComps; bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> getAlt()->getNComps(); func = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())-> getTintTransformFunc(); }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
958
PSOutCustomColor::PSOutCustomColor(double cA, double mA, double yA, double kA, GooString *nameA) { c = cA; m = mA; y = yA; k = kA; name = nameA; next = NULL; }
DoS Exec Code Overflow
0
PSOutCustomColor::PSOutCustomColor(double cA, double mA, double yA, double kA, GooString *nameA) { c = cA; m = mA; y = yA; k = kA; name = nameA; next = NULL; }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
959
PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog, char *psTitle, int firstPage, int lastPage, PSOutMode modeA, int paperWidthA, int paperHeightA, GBool duplexA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, GBool forceRasterizeA, GBool manualCtrlA) { FILE *f; PSFileType fileTypeA; underlayCbk = NULL; underlayCbkData = NULL; overlayCbk = NULL; overlayCbkData = NULL; fontIDs = NULL; fontFileIDs = NULL; fontFileNames = NULL; font8Info = NULL; font16Enc = NULL; imgIDs = NULL; formIDs = NULL; xobjStack = NULL; embFontList = NULL; customColors = NULL; haveTextClip = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; if (!strcmp(fileName, "-")) { fileTypeA = psStdout; f = stdout; } else if (fileName[0] == '|') { fileTypeA = psPipe; #ifdef HAVE_POPEN #ifndef WIN32 signal(SIGPIPE, (SignalFunc)SIG_IGN); #endif if (!(f = popen(fileName + 1, "w"))) { error(-1, "Couldn't run print command '%s'", fileName); ok = gFalse; return; } #else error(-1, "Print commands are not supported ('%s')", fileName); ok = gFalse; return; #endif } else { fileTypeA = psFile; if (!(f = fopen(fileName, "w"))) { error(-1, "Couldn't open PostScript file '%s'", fileName); ok = gFalse; return; } } init(outputToFile, f, fileTypeA, psTitle, xrefA, catalog, firstPage, lastPage, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, duplexA); }
DoS Exec Code Overflow
0
PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog, char *psTitle, int firstPage, int lastPage, PSOutMode modeA, int paperWidthA, int paperHeightA, GBool duplexA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, GBool forceRasterizeA, GBool manualCtrlA) { FILE *f; PSFileType fileTypeA; underlayCbk = NULL; underlayCbkData = NULL; overlayCbk = NULL; overlayCbkData = NULL; fontIDs = NULL; fontFileIDs = NULL; fontFileNames = NULL; font8Info = NULL; font16Enc = NULL; imgIDs = NULL; formIDs = NULL; xobjStack = NULL; embFontList = NULL; customColors = NULL; haveTextClip = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; if (!strcmp(fileName, "-")) { fileTypeA = psStdout; f = stdout; } else if (fileName[0] == '|') { fileTypeA = psPipe; #ifdef HAVE_POPEN #ifndef WIN32 signal(SIGPIPE, (SignalFunc)SIG_IGN); #endif if (!(f = popen(fileName + 1, "w"))) { error(-1, "Couldn't run print command '%s'", fileName); ok = gFalse; return; } #else error(-1, "Print commands are not supported ('%s')", fileName); ok = gFalse; return; #endif } else { fileTypeA = psFile; if (!(f = fopen(fileName, "w"))) { error(-1, "Couldn't open PostScript file '%s'", fileName); ok = gFalse; return; } } init(outputToFile, f, fileTypeA, psTitle, xrefA, catalog, firstPage, lastPage, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, duplexA); }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
960
PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *psTitle, XRef *xrefA, Catalog *catalog, int firstPage, int lastPage, PSOutMode modeA, int paperWidthA, int paperHeightA, GBool duplexA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, GBool forceRasterizeA, GBool manualCtrlA) { underlayCbk = NULL; underlayCbkData = NULL; overlayCbk = NULL; overlayCbkData = NULL; fontIDs = NULL; fontFileIDs = NULL; fontFileNames = NULL; font8Info = NULL; font16Enc = NULL; imgIDs = NULL; formIDs = NULL; xobjStack = NULL; embFontList = NULL; customColors = NULL; haveTextClip = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; init(outputFuncA, outputStreamA, psGeneric, psTitle, xrefA, catalog, firstPage, lastPage, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, duplexA); }
DoS Exec Code Overflow
0
PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *psTitle, XRef *xrefA, Catalog *catalog, int firstPage, int lastPage, PSOutMode modeA, int paperWidthA, int paperHeightA, GBool duplexA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, GBool forceRasterizeA, GBool manualCtrlA) { underlayCbk = NULL; underlayCbkData = NULL; overlayCbk = NULL; overlayCbkData = NULL; fontIDs = NULL; fontFileIDs = NULL; fontFileNames = NULL; font8Info = NULL; font16Enc = NULL; imgIDs = NULL; formIDs = NULL; xobjStack = NULL; embFontList = NULL; customColors = NULL; haveTextClip = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; init(outputFuncA, outputStreamA, psGeneric, psTitle, xrefA, catalog, firstPage, lastPage, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, duplexA); }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
961
void PSOutputDev::addCustomColor(GfxSeparationColorSpace *sepCS) { PSOutCustomColor *cc; GfxColor color; GfxCMYK cmyk; for (cc = customColors; cc; cc = cc->next) { if (!cc->name->cmp(sepCS->getName())) { return; } } color.c[0] = gfxColorComp1; sepCS->getCMYK(&color, &cmyk); cc = new PSOutCustomColor(colToDbl(cmyk.c), colToDbl(cmyk.m), colToDbl(cmyk.y), colToDbl(cmyk.k), sepCS->getName()->copy()); cc->next = customColors; customColors = cc; }
DoS Exec Code Overflow
0
void PSOutputDev::addCustomColor(GfxSeparationColorSpace *sepCS) { PSOutCustomColor *cc; GfxColor color; GfxCMYK cmyk; for (cc = customColors; cc; cc = cc->next) { if (!cc->name->cmp(sepCS->getName())) { return; } } color.c[0] = gfxColorComp1; sepCS->getCMYK(&color, &cmyk); cc = new PSOutCustomColor(colToDbl(cmyk.c), colToDbl(cmyk.m), colToDbl(cmyk.y), colToDbl(cmyk.k), sepCS->getName()->copy()); cc->next = customColors; customColors = cc; }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
962
void PSOutputDev::addProcessColor(double c, double m, double y, double k) { if (c > 0) { processColors |= psProcessCyan; } if (m > 0) { processColors |= psProcessMagenta; } if (y > 0) { processColors |= psProcessYellow; } if (k > 0) { processColors |= psProcessBlack; } }
DoS Exec Code Overflow
0
void PSOutputDev::addProcessColor(double c, double m, double y, double k) { if (c > 0) { processColors |= psProcessCyan; } if (m > 0) { processColors |= psProcessMagenta; } if (y > 0) { processColors |= psProcessYellow; } if (k > 0) { processColors |= psProcessBlack; } }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
963
GBool PSOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, x1, y1, dx, dy, mul; double tMin, tMax, t, t0, t1; int i; if (level == psLevel2Sep || level == psLevel3Sep) { if (shading->getColorSpace()->getMode() != csDeviceCMYK) { return gFalse; } processColors |= psProcessCMYK; } state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); shading->getCoords(&x0, &y0, &x1, &y1); dx = x1 - x0; dy = y1 - y0; if (fabs(dx) < 0.01 && fabs(dy) < 0.01) { return gTrue; } else { mul = 1 / (dx * dx + dy * dy); tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } if (tMin < 0 && !shading->getExtend0()) { tMin = 0; } if (tMax > 1 && !shading->getExtend1()) { tMax = 1; } } t0 = shading->getDomain0(); t1 = shading->getDomain1(); writePSFmt("/t0 {0:.4g} def\n", t0); writePSFmt("/t1 {0:.4g} def\n", t1); writePSFmt("/dt {0:.4g} def\n", t1 - t0); writePSFmt("/x0 {0:.4g} def\n", x0); writePSFmt("/y0 {0:.4g} def\n", y0); writePSFmt("/dx {0:.4g} def\n", x1 - x0); writePSFmt("/x1 {0:.4g} def\n", x1); writePSFmt("/y1 {0:.4g} def\n", y1); writePSFmt("/dy {0:.4g} def\n", y1 - y0); writePSFmt("/xMin {0:.4g} def\n", xMin); writePSFmt("/yMin {0:.4g} def\n", yMin); writePSFmt("/xMax {0:.4g} def\n", xMax); writePSFmt("/yMax {0:.4g} def\n", yMax); writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); if (shading->getNFuncs() == 1) { writePS("/func "); cvtFunction(shading->getFunc(0)); writePS("def\n"); } else { writePS("/func {\n"); for (i = 0; i < shading->getNFuncs(); ++i) { if (i < shading->getNFuncs() - 1) { writePS("dup\n"); } cvtFunction(shading->getFunc(i)); writePS("exec\n"); if (i < shading->getNFuncs() - 1) { writePS("exch\n"); } } writePS("} def\n"); } writePSFmt("{0:.4g} {1:.4g} 0 axialSH\n", tMin, tMax); return gTrue; }
DoS Exec Code Overflow
0
GBool PSOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading) { double xMin, yMin, xMax, yMax; double x0, y0, x1, y1, dx, dy, mul; double tMin, tMax, t, t0, t1; int i; if (level == psLevel2Sep || level == psLevel3Sep) { if (shading->getColorSpace()->getMode() != csDeviceCMYK) { return gFalse; } processColors |= psProcessCMYK; } state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax); shading->getCoords(&x0, &y0, &x1, &y1); dx = x1 - x0; dy = y1 - y0; if (fabs(dx) < 0.01 && fabs(dy) < 0.01) { return gTrue; } else { mul = 1 / (dx * dx + dy * dy); tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul; t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul; if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } if (tMin < 0 && !shading->getExtend0()) { tMin = 0; } if (tMax > 1 && !shading->getExtend1()) { tMax = 1; } } t0 = shading->getDomain0(); t1 = shading->getDomain1(); writePSFmt("/t0 {0:.4g} def\n", t0); writePSFmt("/t1 {0:.4g} def\n", t1); writePSFmt("/dt {0:.4g} def\n", t1 - t0); writePSFmt("/x0 {0:.4g} def\n", x0); writePSFmt("/y0 {0:.4g} def\n", y0); writePSFmt("/dx {0:.4g} def\n", x1 - x0); writePSFmt("/x1 {0:.4g} def\n", x1); writePSFmt("/y1 {0:.4g} def\n", y1); writePSFmt("/dy {0:.4g} def\n", y1 - y0); writePSFmt("/xMin {0:.4g} def\n", xMin); writePSFmt("/yMin {0:.4g} def\n", yMin); writePSFmt("/xMax {0:.4g} def\n", xMax); writePSFmt("/yMax {0:.4g} def\n", yMax); writePSFmt("/n {0:d} def\n", shading->getColorSpace()->getNComps()); if (shading->getNFuncs() == 1) { writePS("/func "); cvtFunction(shading->getFunc(0)); writePS("def\n"); } else { writePS("/func {\n"); for (i = 0; i < shading->getNFuncs(); ++i) { if (i < shading->getNFuncs() - 1) { writePS("dup\n"); } cvtFunction(shading->getFunc(i)); writePS("exec\n"); if (i < shading->getNFuncs() - 1) { writePS("exch\n"); } } writePS("} def\n"); } writePSFmt("{0:.4g} {1:.4g} 0 axialSH\n", tMin, tMax); return gTrue; }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
964
GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, int rotateA, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { #if HAVE_SPLASH PreScanOutputDev *scan; GBool rasterize; SplashOutputDev *splashOut; SplashColor paperColor; PDFRectangle box; GfxState *state; SplashBitmap *bitmap; Stream *str0, *str; Object obj; Guchar *p; Guchar col[4]; double m0, m1, m2, m3, m4, m5; int c, w, h, x, y, comp, i; if (!forceRasterize) { scan = new PreScanOutputDev(); page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); rasterize = scan->usesTransparency(); delete scan; } else { rasterize = gTrue; } if (!rasterize) { return gTrue; } if (level == psLevel1) { paperColor[0] = 0xff; splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, paperColor, gTrue, gFalse); #if SPLASH_CMYK } else if (level == psLevel1Sep) { paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, paperColor, gTrue, gFalse); #endif } else { paperColor[0] = paperColor[1] = paperColor[2] = 0xff; splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor, gTrue, gFalse); } splashOut->startDoc(xref); page->displaySlice(splashOut, splashDPI, splashDPI, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); page->makeBox(splashDPI, splashDPI, rotateA, useMediaBox, gFalse, sliceX, sliceY, sliceW, sliceH, &box, &crop); rotateA += page->getRotate(); if (rotateA >= 360) { rotateA -= 360; } else if (rotateA < 0) { rotateA += 360; } state = new GfxState(splashDPI, splashDPI, &box, rotateA, gFalse); startPage(page->getNum(), state); delete state; switch (rotateA) { case 0: default: // this should never happen m0 = box.x2 - box.x1; m1 = 0; m2 = 0; m3 = box.y2 - box.y1; m4 = box.x1; m5 = box.y1; break; case 90: m0 = 0; m1 = box.y2 - box.y1; m2 = -(box.x2 - box.x1); m3 = 0; m4 = box.x2; m5 = box.y1; break; case 180: m0 = -(box.x2 - box.x1); m1 = 0; m2 = 0; m3 = -(box.y2 - box.y1); m4 = box.x2; m5 = box.y2; break; case 270: m0 = 0; m1 = -(box.y2 - box.y1); m2 = box.x2 - box.x1; m3 = 0; m4 = box.x1; m5 = box.y2; break; } bitmap = splashOut->getBitmap(); w = bitmap->getWidth(); h = bitmap->getHeight(); writePS("gsave\n"); writePSFmt("[{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} {5:.4g}] concat\n", m0, m1, m2, m3, m4, m5); switch (level) { case psLevel1: writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1\n", w, h, w, -h, h); p = bitmap->getDataPtr(); i = 0; for (y = 0; y < h; ++y) { for (x = 0; x < w; ++x) { writePSFmt("{0:02x}", *p++); if (++i == 32) { writePSChar('\n'); i = 0; } } } if (i != 0) { writePSChar('\n'); } break; case psLevel1Sep: writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1Sep\n", w, h, w, -h, h); p = bitmap->getDataPtr(); i = 0; col[0] = col[1] = col[2] = col[3] = 0; for (y = 0; y < h; ++y) { for (comp = 0; comp < 4; ++comp) { for (x = 0; x < w; ++x) { writePSFmt("{0:02x}", p[4*x + comp]); col[comp] |= p[4*x + comp]; if (++i == 32) { writePSChar('\n'); i = 0; } } } p += bitmap->getRowSize(); } if (i != 0) { writePSChar('\n'); } if (col[0]) { processColors |= psProcessCyan; } if (col[1]) { processColors |= psProcessMagenta; } if (col[2]) { processColors |= psProcessYellow; } if (col[3]) { processColors |= psProcessBlack; } break; case psLevel2: case psLevel2Sep: case psLevel3: case psLevel3Sep: writePS("/DeviceRGB setcolorspace\n"); writePS("<<\n /ImageType 1\n"); writePSFmt(" /Width {0:d}\n", bitmap->getWidth()); writePSFmt(" /Height {0:d}\n", bitmap->getHeight()); writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", w, -h, h); writePS(" /BitsPerComponent 8\n"); writePS(" /Decode [0 1 0 1 0 1]\n"); writePS(" /DataSource currentfile\n"); if (globalParams->getPSASCIIHex()) { writePS(" /ASCIIHexDecode filter\n"); } else { writePS(" /ASCII85Decode filter\n"); } writePS(" /RunLengthDecode filter\n"); writePS(">>\n"); writePS("image\n"); obj.initNull(); str0 = new MemStream((char *)bitmap->getDataPtr(), 0, w * h * 3, &obj); str = new RunLengthEncoder(str0); if (globalParams->getPSASCIIHex()) { str = new ASCIIHexEncoder(str); } else { str = new ASCII85Encoder(str); } str->reset(); while ((c = str->getChar()) != EOF) { writePSChar(c); } str->close(); delete str; delete str0; processColors |= psProcessCMYK; break; } delete splashOut; writePS("grestore\n"); endPage(); return gFalse; #else return gTrue; #endif }
DoS Exec Code Overflow
0
GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, int rotateA, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, Catalog *catalog, GBool (*abortCheckCbk)(void *data), void *abortCheckCbkData) { #if HAVE_SPLASH PreScanOutputDev *scan; GBool rasterize; SplashOutputDev *splashOut; SplashColor paperColor; PDFRectangle box; GfxState *state; SplashBitmap *bitmap; Stream *str0, *str; Object obj; Guchar *p; Guchar col[4]; double m0, m1, m2, m3, m4, m5; int c, w, h, x, y, comp, i; if (!forceRasterize) { scan = new PreScanOutputDev(); page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); rasterize = scan->usesTransparency(); delete scan; } else { rasterize = gTrue; } if (!rasterize) { return gTrue; } if (level == psLevel1) { paperColor[0] = 0xff; splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, paperColor, gTrue, gFalse); #if SPLASH_CMYK } else if (level == psLevel1Sep) { paperColor[0] = paperColor[1] = paperColor[2] = paperColor[3] = 0; splashOut = new SplashOutputDev(splashModeCMYK8, 1, gFalse, paperColor, gTrue, gFalse); #endif } else { paperColor[0] = paperColor[1] = paperColor[2] = 0xff; splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor, gTrue, gFalse); } splashOut->startDoc(xref); page->displaySlice(splashOut, splashDPI, splashDPI, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, printing, catalog, abortCheckCbk, abortCheckCbkData); page->makeBox(splashDPI, splashDPI, rotateA, useMediaBox, gFalse, sliceX, sliceY, sliceW, sliceH, &box, &crop); rotateA += page->getRotate(); if (rotateA >= 360) { rotateA -= 360; } else if (rotateA < 0) { rotateA += 360; } state = new GfxState(splashDPI, splashDPI, &box, rotateA, gFalse); startPage(page->getNum(), state); delete state; switch (rotateA) { case 0: default: // this should never happen m0 = box.x2 - box.x1; m1 = 0; m2 = 0; m3 = box.y2 - box.y1; m4 = box.x1; m5 = box.y1; break; case 90: m0 = 0; m1 = box.y2 - box.y1; m2 = -(box.x2 - box.x1); m3 = 0; m4 = box.x2; m5 = box.y1; break; case 180: m0 = -(box.x2 - box.x1); m1 = 0; m2 = 0; m3 = -(box.y2 - box.y1); m4 = box.x2; m5 = box.y2; break; case 270: m0 = 0; m1 = -(box.y2 - box.y1); m2 = box.x2 - box.x1; m3 = 0; m4 = box.x1; m5 = box.y2; break; } bitmap = splashOut->getBitmap(); w = bitmap->getWidth(); h = bitmap->getHeight(); writePS("gsave\n"); writePSFmt("[{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} {5:.4g}] concat\n", m0, m1, m2, m3, m4, m5); switch (level) { case psLevel1: writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1\n", w, h, w, -h, h); p = bitmap->getDataPtr(); i = 0; for (y = 0; y < h; ++y) { for (x = 0; x < w; ++x) { writePSFmt("{0:02x}", *p++); if (++i == 32) { writePSChar('\n'); i = 0; } } } if (i != 0) { writePSChar('\n'); } break; case psLevel1Sep: writePSFmt("{0:d} {1:d} 8 [{2:d} 0 0 {3:d} 0 {4:d}] pdfIm1Sep\n", w, h, w, -h, h); p = bitmap->getDataPtr(); i = 0; col[0] = col[1] = col[2] = col[3] = 0; for (y = 0; y < h; ++y) { for (comp = 0; comp < 4; ++comp) { for (x = 0; x < w; ++x) { writePSFmt("{0:02x}", p[4*x + comp]); col[comp] |= p[4*x + comp]; if (++i == 32) { writePSChar('\n'); i = 0; } } } p += bitmap->getRowSize(); } if (i != 0) { writePSChar('\n'); } if (col[0]) { processColors |= psProcessCyan; } if (col[1]) { processColors |= psProcessMagenta; } if (col[2]) { processColors |= psProcessYellow; } if (col[3]) { processColors |= psProcessBlack; } break; case psLevel2: case psLevel2Sep: case psLevel3: case psLevel3Sep: writePS("/DeviceRGB setcolorspace\n"); writePS("<<\n /ImageType 1\n"); writePSFmt(" /Width {0:d}\n", bitmap->getWidth()); writePSFmt(" /Height {0:d}\n", bitmap->getHeight()); writePSFmt(" /ImageMatrix [{0:d} 0 0 {1:d} 0 {2:d}]\n", w, -h, h); writePS(" /BitsPerComponent 8\n"); writePS(" /Decode [0 1 0 1 0 1]\n"); writePS(" /DataSource currentfile\n"); if (globalParams->getPSASCIIHex()) { writePS(" /ASCIIHexDecode filter\n"); } else { writePS(" /ASCII85Decode filter\n"); } writePS(" /RunLengthDecode filter\n"); writePS(">>\n"); writePS("image\n"); obj.initNull(); str0 = new MemStream((char *)bitmap->getDataPtr(), 0, w * h * 3, &obj); str = new RunLengthEncoder(str0); if (globalParams->getPSASCIIHex()) { str = new ASCIIHexEncoder(str); } else { str = new ASCII85Encoder(str); } str->reset(); while ((c = str->getChar()) != EOF) { writePSChar(c); } str->close(); delete str; delete str0; processColors |= psProcessCMYK; break; } delete splashOut; writePS("grestore\n"); endPage(); return gFalse; #else return gTrue; #endif }
@@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> @@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); if (n) { - codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); + codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); } else { codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); @@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, width, -height, height); // allocate a line buffer - lineBuf = (Guchar *)gmalloc(4 * width); + lineBuf = (Guchar *)gmallocn(width, 4); // set up to process the data stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
CWE-189
null
null
965
Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, SplashScreenParams *screenParams) { int i; bitmap = bitmapA; vectorAntialias = vectorAntialiasA; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenParams); if (vectorAntialias) { aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, 1, splashModeMono1, gFalse); for (i = 0; i <= splashAASize * splashAASize; ++i) { aaGamma[i] = splashPow((SplashCoord)i / (SplashCoord)(splashAASize * splashAASize), 1.5); } } else { aaBuf = NULL; } clearModRegion(); debugMode = gFalse; }
DoS Exec Code Overflow
0
Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, SplashScreenParams *screenParams) { int i; bitmap = bitmapA; vectorAntialias = vectorAntialiasA; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenParams); if (vectorAntialias) { aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, 1, splashModeMono1, gFalse); for (i = 0; i <= splashAASize * splashAASize; ++i) { aaGamma[i] = splashPow((SplashCoord)i / (SplashCoord)(splashAASize * splashAASize), 1.5); } } else { aaBuf = NULL; } clearModRegion(); debugMode = gFalse; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
966
Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, SplashScreen *screenA) { int i; bitmap = bitmapA; vectorAntialias = vectorAntialiasA; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenA); if (vectorAntialias) { aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, 1, splashModeMono1, gFalse); for (i = 0; i <= splashAASize * splashAASize; ++i) { aaGamma[i] = splashPow((SplashCoord)i / (SplashCoord)(splashAASize * splashAASize), 1.5); } } else { aaBuf = NULL; } clearModRegion(); debugMode = gFalse; }
DoS Exec Code Overflow
0
Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, SplashScreen *screenA) { int i; bitmap = bitmapA; vectorAntialias = vectorAntialiasA; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenA); if (vectorAntialias) { aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, 1, splashModeMono1, gFalse); for (i = 0; i <= splashAASize * splashAASize; ++i) { aaGamma[i] = splashPow((SplashCoord)i / (SplashCoord)(splashAASize * splashAASize), 1.5); } } else { aaBuf = NULL; } clearModRegion(); debugMode = gFalse; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
967
static void blendXor(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = src[i] ^ dest[i]; } }
DoS Exec Code Overflow
0
static void blendXor(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; for (i = 0; i < splashColorModeNComps[cm]; ++i) { blend[i] = src[i] ^ dest[i]; } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
968
SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h) { SplashColor pixel; SplashColorPtr p; Guchar *q; int x, y, mask; if (src->mode != bitmap->mode) { return splashErrModeMismatch; } switch (bitmap->mode) { case splashModeMono1: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + (xDest >> 3)]; mask = 0x80 >> (xDest & 7); for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); if (pixel[0]) { *p |= mask; } else { *p &= ~mask; } if (!(mask >>= 1)) { mask = 0x80; ++p; } } } break; case splashModeMono8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; } } break; case splashModeRGB8: case splashModeBGR8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; } } break; case splashModeXBGR8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; *p++ = 255; } } break; #if SPLASH_CMYK case splashModeCMYK8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; *p++ = pixel[3]; } } break; #endif } if (bitmap->alpha) { for (y = 0; y < h; ++y) { q = &bitmap->alpha[(yDest + y) * bitmap->width + xDest]; for (x = 0; x < w; ++x) { *q++ = 0x00; } } } return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h) { SplashColor pixel; SplashColorPtr p; Guchar *q; int x, y, mask; if (src->mode != bitmap->mode) { return splashErrModeMismatch; } switch (bitmap->mode) { case splashModeMono1: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + (xDest >> 3)]; mask = 0x80 >> (xDest & 7); for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); if (pixel[0]) { *p |= mask; } else { *p &= ~mask; } if (!(mask >>= 1)) { mask = 0x80; ++p; } } } break; case splashModeMono8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; } } break; case splashModeRGB8: case splashModeBGR8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; } } break; case splashModeXBGR8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; *p++ = 255; } } break; #if SPLASH_CMYK case splashModeCMYK8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); *p++ = pixel[0]; *p++ = pixel[1]; *p++ = pixel[2]; *p++ = pixel[3]; } } break; #endif } if (bitmap->alpha) { for (y = 0; y < h; ++y) { q = &bitmap->alpha[(yDest + y) * bitmap->width + xDest]; for (x = 0; x < w; ++x) { *q++ = 0x00; } } } return splashOk; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
969
void Splash::clear(SplashColorPtr color, Guchar alpha) { SplashColorPtr row, p; Guchar mono; int x, y; switch (bitmap->mode) { case splashModeMono1: mono = (color[0] & 0x80) ? 0xff : 0x00; if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), mono, -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, mono, bitmap->rowSize * bitmap->height); } break; case splashModeMono8: if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } break; case splashModeRGB8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[2]; *p++ = color[1]; *p++ = color[0]; } row += bitmap->rowSize; } } break; case splashModeXBGR8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; *p++ = 255; } row += bitmap->rowSize; } } break; case splashModeBGR8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; } row += bitmap->rowSize; } } break; #if SPLASH_CMYK case splashModeCMYK8: if (color[0] == color[1] && color[1] == color[2] && color[2] == color[3]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; *p++ = color[3]; } row += bitmap->rowSize; } } break; #endif } if (bitmap->alpha) { memset(bitmap->alpha, alpha, bitmap->width * bitmap->height); } updateModX(0); updateModY(0); updateModX(bitmap->width - 1); updateModY(bitmap->height - 1); }
DoS Exec Code Overflow
0
void Splash::clear(SplashColorPtr color, Guchar alpha) { SplashColorPtr row, p; Guchar mono; int x, y; switch (bitmap->mode) { case splashModeMono1: mono = (color[0] & 0x80) ? 0xff : 0x00; if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), mono, -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, mono, bitmap->rowSize * bitmap->height); } break; case splashModeMono8: if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } break; case splashModeRGB8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[2]; *p++ = color[1]; *p++ = color[0]; } row += bitmap->rowSize; } } break; case splashModeXBGR8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; *p++ = 255; } row += bitmap->rowSize; } } break; case splashModeBGR8: if (color[0] == color[1] && color[1] == color[2]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; } row += bitmap->rowSize; } } break; #if SPLASH_CMYK case splashModeCMYK8: if (color[0] == color[1] && color[1] == color[2] && color[2] == color[3]) { if (bitmap->rowSize < 0) { memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), color[0], -bitmap->rowSize * bitmap->height); } else { memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); } } else { row = bitmap->data; for (y = 0; y < bitmap->height; ++y) { p = row; for (x = 0; x < bitmap->width; ++x) { *p++ = color[0]; *p++ = color[1]; *p++ = color[2]; *p++ = color[3]; } row += bitmap->rowSize; } } break; #endif } if (bitmap->alpha) { memset(bitmap->alpha, alpha, bitmap->width * bitmap->height); } updateModX(0); updateModY(0); updateModX(bitmap->width - 1); updateModY(bitmap->height - 1); }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
970
void Splash::clearModRegion() { modXMin = bitmap->getWidth(); modYMin = bitmap->getHeight(); modXMax = -1; modYMax = -1; }
DoS Exec Code Overflow
0
void Splash::clearModRegion() { modXMin = bitmap->getWidth(); modYMin = bitmap->getHeight(); modXMax = -1; modYMax = -1; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
971
SplashError Splash::clipToPath(SplashPath *path, GBool eo) { return state->clip->clipToPath(path, state->matrix, state->flatness, eo); }
DoS Exec Code Overflow
0
SplashError Splash::clipToPath(SplashPath *path, GBool eo) { return state->clip->clipToPath(path, state->matrix, state->flatness, eo); }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
972
SplashError Splash::clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1) { return state->clip->clipToRect(x0, y0, x1, y1); }
DoS Exec Code Overflow
0
SplashError Splash::clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1) { return state->clip->clipToRect(x0, y0, x1, y1); }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
973
SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h, GBool noClip, GBool nonIsolated) { SplashPipe pipe; SplashColor pixel; Guchar alpha; Guchar *ap; int x, y; if (src->mode != bitmap->mode) { return splashErrModeMismatch; } if (src->alpha) { pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha, gTrue, nonIsolated); for (y = 0; y < h; ++y) { pipeSetXY(&pipe, xDest, yDest + y); ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); alpha = *ap++; if (noClip || state->clip->test(xDest + x, yDest + y)) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(xDest + x); updateModY(yDest + y); } else { pipeIncX(&pipe); } } } } else { pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha, gFalse, nonIsolated); for (y = 0; y < h; ++y) { pipeSetXY(&pipe, xDest, yDest + y); for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); if (noClip || state->clip->test(xDest + x, yDest + y)) { pipeRun(&pipe); updateModX(xDest + x); updateModY(yDest + y); } else { pipeIncX(&pipe); } } } } return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h, GBool noClip, GBool nonIsolated) { SplashPipe pipe; SplashColor pixel; Guchar alpha; Guchar *ap; int x, y; if (src->mode != bitmap->mode) { return splashErrModeMismatch; } if (src->alpha) { pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha, gTrue, nonIsolated); for (y = 0; y < h; ++y) { pipeSetXY(&pipe, xDest, yDest + y); ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); alpha = *ap++; if (noClip || state->clip->test(xDest + x, yDest + y)) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(xDest + x); updateModY(yDest + y); } else { pipeIncX(&pipe); } } } } else { pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha, gFalse, nonIsolated); for (y = 0; y < h; ++y) { pipeSetXY(&pipe, xDest, yDest + y); for (x = 0; x < w; ++x) { src->getPixel(xSrc + x, ySrc + y, pixel); if (noClip || state->clip->test(xDest + x, yDest + y)) { pipeRun(&pipe); updateModX(xDest + x); updateModY(yDest + y); } else { pipeIncX(&pipe); } } } } return splashOk; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
974
void Splash::compositeBackground(SplashColorPtr color) { SplashColorPtr p; Guchar *q; Guchar alpha, alpha1, c, color0, color1, color2; #if SPLASH_CMYK Guchar color3; #endif int x, y, mask; switch (bitmap->mode) { case splashModeMono1: color0 = color[0]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; mask = 0x80; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; c = (*p & mask) ? 0xff : 0x00; c = div255(alpha1 * color0 + alpha * c); if (c & 0x80) { *p |= mask; } else { *p &= ~mask; } if (!(mask >>= 1)) { mask = 0x80; ++p; } } } break; case splashModeMono8: color0 = color[0]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); ++p; } } break; case splashModeRGB8: case splashModeBGR8: color0 = color[0]; color1 = color[1]; color2 = color[2]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p += 3; } } break; case splashModeXBGR8: color0 = color[0]; color1 = color[1]; color2 = color[2]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p[3] = 255; p += 4; } } break; #if SPLASH_CMYK case splashModeCMYK8: color0 = color[0]; color1 = color[1]; color2 = color[2]; color3 = color[3]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p[3] = div255(alpha1 * color3 + alpha * p[3]); p += 4; } } break; #endif } memset(bitmap->alpha, 255, bitmap->width * bitmap->height); }
DoS Exec Code Overflow
0
void Splash::compositeBackground(SplashColorPtr color) { SplashColorPtr p; Guchar *q; Guchar alpha, alpha1, c, color0, color1, color2; #if SPLASH_CMYK Guchar color3; #endif int x, y, mask; switch (bitmap->mode) { case splashModeMono1: color0 = color[0]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; mask = 0x80; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; c = (*p & mask) ? 0xff : 0x00; c = div255(alpha1 * color0 + alpha * c); if (c & 0x80) { *p |= mask; } else { *p &= ~mask; } if (!(mask >>= 1)) { mask = 0x80; ++p; } } } break; case splashModeMono8: color0 = color[0]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); ++p; } } break; case splashModeRGB8: case splashModeBGR8: color0 = color[0]; color1 = color[1]; color2 = color[2]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p += 3; } } break; case splashModeXBGR8: color0 = color[0]; color1 = color[1]; color2 = color[2]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p[3] = 255; p += 4; } } break; #if SPLASH_CMYK case splashModeCMYK8: color0 = color[0]; color1 = color[1]; color2 = color[2]; color3 = color[3]; for (y = 0; y < bitmap->height; ++y) { p = &bitmap->data[y * bitmap->rowSize]; q = &bitmap->alpha[y * bitmap->width]; for (x = 0; x < bitmap->width; ++x) { alpha = *q++; alpha1 = 255 - alpha; p[0] = div255(alpha1 * color0 + alpha * p[0]); p[1] = div255(alpha1 * color1 + alpha * p[1]); p[2] = div255(alpha1 * color2 + alpha * p[2]); p[3] = div255(alpha1 * color3 + alpha * p[3]); p += 4; } } break; #endif } memset(bitmap->alpha, 255, bitmap->width * bitmap->height); }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
975
inline void Splash::drawAALine(SplashPipe *pipe, int x0, int x1, int y) { #if splashAASize == 4 static int bitCount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; SplashColorPtr p0, p1, p2, p3; int t; #else SplashColorPtr p; int xx, yy, t; #endif int x; #if splashAASize == 4 p0 = aaBuf->getDataPtr() + (x0 >> 1); p1 = p0 + aaBuf->getRowSize(); p2 = p1 + aaBuf->getRowSize(); p3 = p2 + aaBuf->getRowSize(); #endif pipeSetXY(pipe, x0, y); for (x = x0; x <= x1; ++x) { #if splashAASize == 4 if (x & 1) { t = bitCount4[*p0 & 0x0f] + bitCount4[*p1 & 0x0f] + bitCount4[*p2 & 0x0f] + bitCount4[*p3 & 0x0f]; ++p0; ++p1; ++p2; ++p3; } else { t = bitCount4[*p0 >> 4] + bitCount4[*p1 >> 4] + bitCount4[*p2 >> 4] + bitCount4[*p3 >> 4]; } #else t = 0; for (yy = 0; yy < splashAASize; ++yy) { for (xx = 0; xx < splashAASize; ++xx) { p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + ((x * splashAASize + xx) >> 3); t += (*p >> (7 - ((x * splashAASize + xx) & 7))) & 1; } } #endif if (t != 0) { pipe->shape = aaGamma[t]; pipeRun(pipe); updateModX(x); updateModY(y); } else { pipeIncX(pipe); } } }
DoS Exec Code Overflow
0
inline void Splash::drawAALine(SplashPipe *pipe, int x0, int x1, int y) { #if splashAASize == 4 static int bitCount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; SplashColorPtr p0, p1, p2, p3; int t; #else SplashColorPtr p; int xx, yy, t; #endif int x; #if splashAASize == 4 p0 = aaBuf->getDataPtr() + (x0 >> 1); p1 = p0 + aaBuf->getRowSize(); p2 = p1 + aaBuf->getRowSize(); p3 = p2 + aaBuf->getRowSize(); #endif pipeSetXY(pipe, x0, y); for (x = x0; x <= x1; ++x) { #if splashAASize == 4 if (x & 1) { t = bitCount4[*p0 & 0x0f] + bitCount4[*p1 & 0x0f] + bitCount4[*p2 & 0x0f] + bitCount4[*p3 & 0x0f]; ++p0; ++p1; ++p2; ++p3; } else { t = bitCount4[*p0 >> 4] + bitCount4[*p1 >> 4] + bitCount4[*p2 >> 4] + bitCount4[*p3 >> 4]; } #else t = 0; for (yy = 0; yy < splashAASize; ++yy) { for (xx = 0; xx < splashAASize; ++xx) { p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + ((x * splashAASize + xx) >> 3); t += (*p >> (7 - ((x * splashAASize + xx) & 7))) & 1; } } #endif if (t != 0) { pipe->shape = aaGamma[t]; pipeRun(pipe); updateModX(x); updateModY(y); } else { pipeIncX(pipe); } } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
976
inline void Splash::drawAAPixelInit() { aaBufY = -1; }
DoS Exec Code Overflow
0
inline void Splash::drawAAPixelInit() { aaBufY = -1; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
977
inline void Splash::drawPixel(SplashPipe *pipe, int x, int y, GBool noClip) { if (noClip || state->clip->test(x, y)) { pipeSetXY(pipe, x, y); pipeRun(pipe); updateModX(x); updateModY(y); } }
DoS Exec Code Overflow
0
inline void Splash::drawPixel(SplashPipe *pipe, int x, int y, GBool noClip) { if (noClip || state->clip->test(x, y)) { pipeSetXY(pipe, x, y); pipeRun(pipe); updateModX(x); updateModY(y); } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
978
inline void Splash::drawSpan(SplashPipe *pipe, int x0, int x1, int y, GBool noClip) { int x; pipeSetXY(pipe, x0, y); if (noClip) { for (x = x0; x <= x1; ++x) { pipeRun(pipe); } updateModX(x0); updateModX(x1); updateModY(y); } else { for (x = x0; x <= x1; ++x) { if (state->clip->test(x, y)) { pipeRun(pipe); updateModX(x); updateModY(y); } else { pipeIncX(pipe); } } } }
DoS Exec Code Overflow
0
inline void Splash::drawSpan(SplashPipe *pipe, int x0, int x1, int y, GBool noClip) { int x; pipeSetXY(pipe, x0, y); if (noClip) { for (x = x0; x <= x1; ++x) { pipeRun(pipe); } updateModX(x0); updateModX(x1); updateModY(y); } else { for (x = x0; x <= x1; ++x) { if (state->clip->test(x, y)) { pipeRun(pipe); updateModX(x); updateModY(y); } else { pipeIncX(pipe); } } } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
979
void Splash::dumpXPath(SplashXPath *path) { int i; for (i = 0; i < path->length; ++i) { printf(" %4d: x0=%8.2f y0=%8.2f x1=%8.2f y1=%8.2f %s%s%s%s%s%s%s\n", i, (double)path->segs[i].x0, (double)path->segs[i].y0, (double)path->segs[i].x1, (double)path->segs[i].y1, (path->segs[i].flags & splashXPathFirst) ? "F" : " ", (path->segs[i].flags & splashXPathLast) ? "L" : " ", (path->segs[i].flags & splashXPathEnd0) ? "0" : " ", (path->segs[i].flags & splashXPathEnd1) ? "1" : " ", (path->segs[i].flags & splashXPathHoriz) ? "H" : " ", (path->segs[i].flags & splashXPathVert) ? "V" : " ", (path->segs[i].flags & splashXPathFlip) ? "P" : " "); } }
DoS Exec Code Overflow
0
void Splash::dumpXPath(SplashXPath *path) { int i; for (i = 0; i < path->length; ++i) { printf(" %4d: x0=%8.2f y0=%8.2f x1=%8.2f y1=%8.2f %s%s%s%s%s%s%s\n", i, (double)path->segs[i].x0, (double)path->segs[i].y0, (double)path->segs[i].x1, (double)path->segs[i].y1, (path->segs[i].flags & splashXPathFirst) ? "F" : " ", (path->segs[i].flags & splashXPathLast) ? "L" : " ", (path->segs[i].flags & splashXPathEnd0) ? "0" : " ", (path->segs[i].flags & splashXPathEnd1) ? "1" : " ", (path->segs[i].flags & splashXPathHoriz) ? "H" : " ", (path->segs[i].flags & splashXPathVert) ? "V" : " ", (path->segs[i].flags & splashXPathFlip) ? "P" : " "); } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
980
SplashError Splash::fill(SplashPath *path, GBool eo) { if (debugMode) { printf("fill [eo:%d]:\n", eo); dumpPath(path); } return fillWithPattern(path, eo, state->fillPattern, state->fillAlpha); }
DoS Exec Code Overflow
0
SplashError Splash::fill(SplashPath *path, GBool eo) { if (debugMode) { printf("fill [eo:%d]:\n", eo); dumpPath(path); } return fillWithPattern(path, eo, state->fillPattern, state->fillAlpha); }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
981
void Splash::fillGlyph(SplashCoord x, SplashCoord y, SplashGlyphBitmap *glyph) { SplashCoord xt, yt; int x0, y0; transform(state->matrix, x, y, &xt, &yt); x0 = splashFloor(xt); y0 = splashFloor(yt); SplashClipResult clipRes = state->clip->testRect(x0 - glyph->x, y0 - glyph->y, x0 - glyph->x + glyph->w - 1, y0 - glyph->y + glyph->h - 1); if (clipRes != splashClipAllOutside) { fillGlyph2(x0, y0, glyph, clipRes == splashClipAllInside); } opClipRes = clipRes; }
DoS Exec Code Overflow
0
void Splash::fillGlyph(SplashCoord x, SplashCoord y, SplashGlyphBitmap *glyph) { SplashCoord xt, yt; int x0, y0; transform(state->matrix, x, y, &xt, &yt); x0 = splashFloor(xt); y0 = splashFloor(yt); SplashClipResult clipRes = state->clip->testRect(x0 - glyph->x, y0 - glyph->y, x0 - glyph->x + glyph->w - 1, y0 - glyph->y + glyph->h - 1); if (clipRes != splashClipAllOutside) { fillGlyph2(x0, y0, glyph, clipRes == splashClipAllInside); } opClipRes = clipRes; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
982
void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) { SplashPipe pipe; int alpha0, alpha; Guchar *p; int x1, y1, xx, xx1, yy; p = glyph->data; int xStart = x0 - glyph->x; int yStart = y0 - glyph->y; int xxLimit = glyph->w; int yyLimit = glyph->h; if (yStart < 0) { p += glyph->w * -yStart; // move p to the beginning of the first painted row yyLimit += yStart; yStart = 0; } if (xStart < 0) { p += -xStart; // move p to the first painted pixel xxLimit += xStart; xStart = 0; } if (xxLimit + xStart >= bitmap->width) xxLimit = bitmap->width - xStart; if (yyLimit + yStart >= bitmap->height) yyLimit = bitmap->height - yStart; if (noClip) { if (glyph->aa) { pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gTrue, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { alpha = p[xx]; if (alpha != 0) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } p += glyph->w; } } else { const int widthEight = splashCeil(glyph->w / 8.0); pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (alpha0 & 0x80) { pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } alpha0 <<= 1; } } p += widthEight; } } } else { if (glyph->aa) { pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gTrue, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { if (state->clip->test(x1, y1)) { alpha = p[xx]; if (alpha != 0) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } else { pipeIncX(&pipe); } } p += glyph->w; } } else { const int widthEight = splashCeil(glyph->w / 8.0); pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (state->clip->test(x1, y1)) { if (alpha0 & 0x80) { pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } else { pipeIncX(&pipe); } alpha0 <<= 1; } } p += widthEight; } } } }
DoS Exec Code Overflow
0
void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) { SplashPipe pipe; int alpha0, alpha; Guchar *p; int x1, y1, xx, xx1, yy; p = glyph->data; int xStart = x0 - glyph->x; int yStart = y0 - glyph->y; int xxLimit = glyph->w; int yyLimit = glyph->h; if (yStart < 0) { p += glyph->w * -yStart; // move p to the beginning of the first painted row yyLimit += yStart; yStart = 0; } if (xStart < 0) { p += -xStart; // move p to the first painted pixel xxLimit += xStart; xStart = 0; } if (xxLimit + xStart >= bitmap->width) xxLimit = bitmap->width - xStart; if (yyLimit + yStart >= bitmap->height) yyLimit = bitmap->height - yStart; if (noClip) { if (glyph->aa) { pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gTrue, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { alpha = p[xx]; if (alpha != 0) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } p += glyph->w; } } else { const int widthEight = splashCeil(glyph->w / 8.0); pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (alpha0 & 0x80) { pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } alpha0 <<= 1; } } p += widthEight; } } } else { if (glyph->aa) { pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gTrue, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { if (state->clip->test(x1, y1)) { alpha = p[xx]; if (alpha != 0) { pipe.shape = (SplashCoord)(alpha / 255.0); pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } else { pipeIncX(&pipe); } } p += glyph->w; } } else { const int widthEight = splashCeil(glyph->w / 8.0); pipeInit(&pipe, xStart, yStart, state->fillPattern, NULL, state->fillAlpha, gFalse, gFalse); for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { pipeSetXY(&pipe, xStart, y1); for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { alpha0 = p[xx / 8]; for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { if (state->clip->test(x1, y1)) { if (alpha0 & 0x80) { pipeRun(&pipe); updateModX(x1); updateModY(y1); } else { pipeIncX(&pipe); } } else { pipeIncX(&pipe); } alpha0 <<= 1; } } p += widthEight; } } } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
983
SplashError Splash::fillWithPattern(SplashPath *path, GBool eo, SplashPattern *pattern, SplashCoord alpha) { SplashPipe pipe; SplashXPath *xPath; SplashXPathScanner *scanner; int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; SplashClipResult clipRes, clipRes2; if (path->length == 0) { return splashErrEmptyPath; } xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); if (vectorAntialias) { xPath->aaScale(); } xPath->sort(); scanner = new SplashXPathScanner(xPath, eo); if (vectorAntialias) { scanner->getBBoxAA(&xMinI, &yMinI, &xMaxI, &yMaxI); } else { scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); } if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) != splashClipAllOutside) { if (yMinI < state->clip->getYMinI()) { yMinI = state->clip->getYMinI(); } if (yMaxI > state->clip->getYMaxI()) { yMaxI = state->clip->getYMaxI(); } pipeInit(&pipe, 0, yMinI, pattern, NULL, alpha, vectorAntialias, gFalse); if (vectorAntialias) { for (y = yMinI; y <= yMaxI; ++y) { scanner->renderAALine(aaBuf, &x0, &x1, y); if (clipRes != splashClipAllInside) { state->clip->clipAALine(aaBuf, &x0, &x1, y); } drawAALine(&pipe, x0, x1, y); } } else { for (y = yMinI; y <= yMaxI; ++y) { while (scanner->getNextSpan(y, &x0, &x1)) { if (clipRes == splashClipAllInside) { drawSpan(&pipe, x0, x1, y, gTrue); } else { if (x0 < state->clip->getXMinI()) { x0 = state->clip->getXMinI(); } if (x1 > state->clip->getXMaxI()) { x1 = state->clip->getXMaxI(); } clipRes2 = state->clip->testSpan(x0, x1, y); drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); } } } } } opClipRes = clipRes; delete scanner; delete xPath; return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::fillWithPattern(SplashPath *path, GBool eo, SplashPattern *pattern, SplashCoord alpha) { SplashPipe pipe; SplashXPath *xPath; SplashXPathScanner *scanner; int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; SplashClipResult clipRes, clipRes2; if (path->length == 0) { return splashErrEmptyPath; } xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); if (vectorAntialias) { xPath->aaScale(); } xPath->sort(); scanner = new SplashXPathScanner(xPath, eo); if (vectorAntialias) { scanner->getBBoxAA(&xMinI, &yMinI, &xMaxI, &yMaxI); } else { scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); } if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) != splashClipAllOutside) { if (yMinI < state->clip->getYMinI()) { yMinI = state->clip->getYMinI(); } if (yMaxI > state->clip->getYMaxI()) { yMaxI = state->clip->getYMaxI(); } pipeInit(&pipe, 0, yMinI, pattern, NULL, alpha, vectorAntialias, gFalse); if (vectorAntialias) { for (y = yMinI; y <= yMaxI; ++y) { scanner->renderAALine(aaBuf, &x0, &x1, y); if (clipRes != splashClipAllInside) { state->clip->clipAALine(aaBuf, &x0, &x1, y); } drawAALine(&pipe, x0, x1, y); } } else { for (y = yMinI; y <= yMaxI; ++y) { while (scanner->getNextSpan(y, &x0, &x1)) { if (clipRes == splashClipAllInside) { drawSpan(&pipe, x0, x1, y, gTrue); } else { if (x0 < state->clip->getXMinI()) { x0 = state->clip->getXMinI(); } if (x1 > state->clip->getXMaxI()) { x1 = state->clip->getXMaxI(); } clipRes2 = state->clip->testSpan(x0, x1, y); drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); } } } } } opClipRes = clipRes; delete scanner; delete xPath; return splashOk; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
984
void Splash::flattenCurve(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3, SplashCoord *matrix, SplashCoord flatness2, SplashPath *fPath) { SplashCoord cx[splashMaxCurveSplits + 1][3]; SplashCoord cy[splashMaxCurveSplits + 1][3]; int cNext[splashMaxCurveSplits + 1]; SplashCoord xl0, xl1, xl2, xr0, xr1, xr2, xr3, xx1, xx2, xh; SplashCoord yl0, yl1, yl2, yr0, yr1, yr2, yr3, yy1, yy2, yh; SplashCoord dx, dy, mx, my, tx, ty, d1, d2; int p1, p2, p3; p1 = 0; p2 = splashMaxCurveSplits; cx[p1][0] = x0; cy[p1][0] = y0; cx[p1][1] = x1; cy[p1][1] = y1; cx[p1][2] = x2; cy[p1][2] = y2; cx[p2][0] = x3; cy[p2][0] = y3; cNext[p1] = p2; while (p1 < splashMaxCurveSplits) { xl0 = cx[p1][0]; yl0 = cy[p1][0]; xx1 = cx[p1][1]; yy1 = cy[p1][1]; xx2 = cx[p1][2]; yy2 = cy[p1][2]; p2 = cNext[p1]; xr3 = cx[p2][0]; yr3 = cy[p2][0]; transform(matrix, (xl0 + xr3) * 0.5, (yl0 + yr3) * 0.5, &mx, &my); transform(matrix, xx1, yy1, &tx, &ty); dx = tx - mx; dy = ty - my; d1 = dx*dx + dy*dy; transform(matrix, xx2, yy2, &tx, &ty); dx = tx - mx; dy = ty - my; d2 = dx*dx + dy*dy; if (p2 - p1 == 1 || (d1 <= flatness2 && d2 <= flatness2)) { fPath->lineTo(xr3, yr3); p1 = p2; } else { xl1 = (xl0 + xx1) * 0.5; yl1 = (yl0 + yy1) * 0.5; xh = (xx1 + xx2) * 0.5; yh = (yy1 + yy2) * 0.5; xl2 = (xl1 + xh) * 0.5; yl2 = (yl1 + yh) * 0.5; xr2 = (xx2 + xr3) * 0.5; yr2 = (yy2 + yr3) * 0.5; xr1 = (xh + xr2) * 0.5; yr1 = (yh + yr2) * 0.5; xr0 = (xl2 + xr1) * 0.5; yr0 = (yl2 + yr1) * 0.5; p3 = (p1 + p2) / 2; cx[p1][1] = xl1; cy[p1][1] = yl1; cx[p1][2] = xl2; cy[p1][2] = yl2; cNext[p1] = p3; cx[p3][0] = xr0; cy[p3][0] = yr0; cx[p3][1] = xr1; cy[p3][1] = yr1; cx[p3][2] = xr2; cy[p3][2] = yr2; cNext[p3] = p2; } } }
DoS Exec Code Overflow
0
void Splash::flattenCurve(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1, SplashCoord x2, SplashCoord y2, SplashCoord x3, SplashCoord y3, SplashCoord *matrix, SplashCoord flatness2, SplashPath *fPath) { SplashCoord cx[splashMaxCurveSplits + 1][3]; SplashCoord cy[splashMaxCurveSplits + 1][3]; int cNext[splashMaxCurveSplits + 1]; SplashCoord xl0, xl1, xl2, xr0, xr1, xr2, xr3, xx1, xx2, xh; SplashCoord yl0, yl1, yl2, yr0, yr1, yr2, yr3, yy1, yy2, yh; SplashCoord dx, dy, mx, my, tx, ty, d1, d2; int p1, p2, p3; p1 = 0; p2 = splashMaxCurveSplits; cx[p1][0] = x0; cy[p1][0] = y0; cx[p1][1] = x1; cy[p1][1] = y1; cx[p1][2] = x2; cy[p1][2] = y2; cx[p2][0] = x3; cy[p2][0] = y3; cNext[p1] = p2; while (p1 < splashMaxCurveSplits) { xl0 = cx[p1][0]; yl0 = cy[p1][0]; xx1 = cx[p1][1]; yy1 = cy[p1][1]; xx2 = cx[p1][2]; yy2 = cy[p1][2]; p2 = cNext[p1]; xr3 = cx[p2][0]; yr3 = cy[p2][0]; transform(matrix, (xl0 + xr3) * 0.5, (yl0 + yr3) * 0.5, &mx, &my); transform(matrix, xx1, yy1, &tx, &ty); dx = tx - mx; dy = ty - my; d1 = dx*dx + dy*dy; transform(matrix, xx2, yy2, &tx, &ty); dx = tx - mx; dy = ty - my; d2 = dx*dx + dy*dy; if (p2 - p1 == 1 || (d1 <= flatness2 && d2 <= flatness2)) { fPath->lineTo(xr3, yr3); p1 = p2; } else { xl1 = (xl0 + xx1) * 0.5; yl1 = (yl0 + yy1) * 0.5; xh = (xx1 + xx2) * 0.5; yh = (yy1 + yy2) * 0.5; xl2 = (xl1 + xh) * 0.5; yl2 = (yl1 + yh) * 0.5; xr2 = (xx2 + xr3) * 0.5; yr2 = (yy2 + yr3) * 0.5; xr1 = (xh + xr2) * 0.5; yr1 = (yh + yr2) * 0.5; xr0 = (xl2 + xr1) * 0.5; yr0 = (yl2 + yr1) * 0.5; p3 = (p1 + p2) / 2; cx[p1][1] = xl1; cy[p1][1] = yl1; cx[p1][2] = xl2; cy[p1][2] = yl2; cNext[p1] = p3; cx[p3][0] = xr0; cy[p3][0] = yr0; cx[p3][1] = xr1; cy[p3][1] = yr1; cx[p3][2] = xr2; cy[p3][2] = yr2; cNext[p3] = p2; } } }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
985
SplashPath *Splash::flattenPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness) { SplashPath *fPath; SplashCoord flatness2; Guchar flag; int i; fPath = new SplashPath(); flatness2 = flatness * flatness; i = 0; while (i < path->length) { flag = path->flags[i]; if (flag & splashPathFirst) { fPath->moveTo(path->pts[i].x, path->pts[i].y); ++i; } else { if (flag & splashPathCurve) { flattenCurve(path->pts[i-1].x, path->pts[i-1].y, path->pts[i ].x, path->pts[i ].y, path->pts[i+1].x, path->pts[i+1].y, path->pts[i+2].x, path->pts[i+2].y, matrix, flatness2, fPath); i += 3; } else { fPath->lineTo(path->pts[i].x, path->pts[i].y); ++i; } if (path->flags[i-1] & splashPathClosed) { fPath->close(); } } } return fPath; }
DoS Exec Code Overflow
0
SplashPath *Splash::flattenPath(SplashPath *path, SplashCoord *matrix, SplashCoord flatness) { SplashPath *fPath; SplashCoord flatness2; Guchar flag; int i; fPath = new SplashPath(); flatness2 = flatness * flatness; i = 0; while (i < path->length) { flag = path->flags[i]; if (flag & splashPathFirst) { fPath->moveTo(path->pts[i].x, path->pts[i].y); ++i; } else { if (flag & splashPathCurve) { flattenCurve(path->pts[i-1].x, path->pts[i-1].y, path->pts[i ].x, path->pts[i ].y, path->pts[i+1].x, path->pts[i+1].y, path->pts[i+2].x, path->pts[i+2].y, matrix, flatness2, fPath); i += 3; } else { fPath->lineTo(path->pts[i].x, path->pts[i].y); ++i; } if (path->flags[i-1] & splashPathClosed) { fPath->close(); } } } return fPath; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
986
SplashBlendFunc Splash::getBlendFunc() { return state->blendFunc; }
DoS Exec Code Overflow
0
SplashBlendFunc Splash::getBlendFunc() { return state->blendFunc; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
987
SplashCoord Splash::getFillAlpha() { return state->fillAlpha; }
DoS Exec Code Overflow
0
SplashCoord Splash::getFillAlpha() { return state->fillAlpha; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
988
SplashPattern *Splash::getFillPattern() { return state->fillPattern; }
DoS Exec Code Overflow
0
SplashPattern *Splash::getFillPattern() { return state->fillPattern; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
989
GBool Splash::getInNonIsolatedGroup() { return state->inNonIsolatedGroup; }
DoS Exec Code Overflow
0
GBool Splash::getInNonIsolatedGroup() { return state->inNonIsolatedGroup; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
990
int Splash::getLineCap() { return state->lineCap; }
DoS Exec Code Overflow
0
int Splash::getLineCap() { return state->lineCap; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
991
SplashCoord *Splash::getLineDash() { return state->lineDash; }
DoS Exec Code Overflow
0
SplashCoord *Splash::getLineDash() { return state->lineDash; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
992
int Splash::getLineDashLength() { return state->lineDashLength; }
DoS Exec Code Overflow
0
int Splash::getLineDashLength() { return state->lineDashLength; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
993
SplashCoord Splash::getLineDashPhase() { return state->lineDashPhase; }
DoS Exec Code Overflow
0
SplashCoord Splash::getLineDashPhase() { return state->lineDashPhase; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
994
SplashCoord Splash::getMiterLimit() { return state->miterLimit; }
DoS Exec Code Overflow
0
SplashCoord Splash::getMiterLimit() { return state->miterLimit; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
995
SplashScreen *Splash::getScreen() { return state->screen; }
DoS Exec Code Overflow
0
SplashScreen *Splash::getScreen() { return state->screen; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
996
SplashBitmap *Splash::getSoftMask() { return state->softMask; }
DoS Exec Code Overflow
0
SplashBitmap *Splash::getSoftMask() { return state->softMask; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
997
SplashCoord Splash::getStrokeAlpha() { return state->strokeAlpha; }
DoS Exec Code Overflow
0
SplashCoord Splash::getStrokeAlpha() { return state->strokeAlpha; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
998
SplashPattern *Splash::getStrokePattern() { return state->strokePattern; }
DoS Exec Code Overflow
0
SplashPattern *Splash::getStrokePattern() { return state->strokePattern; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
999
SplashPath *Splash::makeDashedPath(SplashPath *path) { SplashPath *dPath; SplashCoord lineDashTotal; SplashCoord lineDashStartPhase, lineDashDist, segLen; SplashCoord x0, y0, x1, y1, xa, ya; GBool lineDashStartOn, lineDashOn, newPath; int lineDashStartIdx, lineDashIdx; int i, j, k; lineDashTotal = 0; for (i = 0; i < state->lineDashLength; ++i) { lineDashTotal += state->lineDash[i]; } lineDashStartPhase = state->lineDashPhase; i = splashFloor(lineDashStartPhase / lineDashTotal); lineDashStartPhase -= (SplashCoord)i * lineDashTotal; lineDashStartOn = gTrue; lineDashStartIdx = 0; while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { lineDashStartOn = !lineDashStartOn; lineDashStartPhase -= state->lineDash[lineDashStartIdx]; ++lineDashStartIdx; } dPath = new SplashPath(); i = 0; while (i < path->length) { for (j = i; j < path->length - 1 && !(path->flags[j] & splashPathLast); ++j) ; lineDashOn = lineDashStartOn; lineDashIdx = lineDashStartIdx; lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase; newPath = gTrue; for (k = i; k < j; ++k) { x0 = path->pts[k].x; y0 = path->pts[k].y; x1 = path->pts[k+1].x; y1 = path->pts[k+1].y; segLen = splashDist(x0, y0, x1, y1); while (segLen > 0) { if (lineDashDist >= segLen) { if (lineDashOn) { if (newPath) { dPath->moveTo(x0, y0); newPath = gFalse; } dPath->lineTo(x1, y1); } lineDashDist -= segLen; segLen = 0; } else { xa = x0 + (lineDashDist / segLen) * (x1 - x0); ya = y0 + (lineDashDist / segLen) * (y1 - y0); if (lineDashOn) { if (newPath) { dPath->moveTo(x0, y0); newPath = gFalse; } dPath->lineTo(xa, ya); } x0 = xa; y0 = ya; segLen -= lineDashDist; lineDashDist = 0; } if (lineDashDist <= 0) { lineDashOn = !lineDashOn; if (++lineDashIdx == state->lineDashLength) { lineDashIdx = 0; } lineDashDist = state->lineDash[lineDashIdx]; newPath = gTrue; } } } i = j + 1; } return dPath; }
DoS Exec Code Overflow
0
SplashPath *Splash::makeDashedPath(SplashPath *path) { SplashPath *dPath; SplashCoord lineDashTotal; SplashCoord lineDashStartPhase, lineDashDist, segLen; SplashCoord x0, y0, x1, y1, xa, ya; GBool lineDashStartOn, lineDashOn, newPath; int lineDashStartIdx, lineDashIdx; int i, j, k; lineDashTotal = 0; for (i = 0; i < state->lineDashLength; ++i) { lineDashTotal += state->lineDash[i]; } lineDashStartPhase = state->lineDashPhase; i = splashFloor(lineDashStartPhase / lineDashTotal); lineDashStartPhase -= (SplashCoord)i * lineDashTotal; lineDashStartOn = gTrue; lineDashStartIdx = 0; while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { lineDashStartOn = !lineDashStartOn; lineDashStartPhase -= state->lineDash[lineDashStartIdx]; ++lineDashStartIdx; } dPath = new SplashPath(); i = 0; while (i < path->length) { for (j = i; j < path->length - 1 && !(path->flags[j] & splashPathLast); ++j) ; lineDashOn = lineDashStartOn; lineDashIdx = lineDashStartIdx; lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase; newPath = gTrue; for (k = i; k < j; ++k) { x0 = path->pts[k].x; y0 = path->pts[k].y; x1 = path->pts[k+1].x; y1 = path->pts[k+1].y; segLen = splashDist(x0, y0, x1, y1); while (segLen > 0) { if (lineDashDist >= segLen) { if (lineDashOn) { if (newPath) { dPath->moveTo(x0, y0); newPath = gFalse; } dPath->lineTo(x1, y1); } lineDashDist -= segLen; segLen = 0; } else { xa = x0 + (lineDashDist / segLen) * (x1 - x0); ya = y0 + (lineDashDist / segLen) * (y1 - y0); if (lineDashOn) { if (newPath) { dPath->moveTo(x0, y0); newPath = gFalse; } dPath->lineTo(xa, ya); } x0 = xa; y0 = ya; segLen -= lineDashDist; lineDashDist = 0; } if (lineDashDist <= 0) { lineDashOn = !lineDashOn; if (++lineDashIdx == state->lineDashLength) { lineDashIdx = 0; } lineDashDist = state->lineDash[lineDashIdx]; newPath = gTrue; } } } i = j + 1; } return dPath; }
@@ -11,7 +11,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-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null