project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,167
11,748
327904148770645625920478099795977980526
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void JBIG2Bitmap::duplicateRow(int yDest, int ySrc) { memcpy(data + yDest * line, data + ySrc * line, line); }
CWE-189
1,169
11,749
269345986773893100799778492120244359081
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,170
11,750
339890504489277417952483634188954837443
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,171
11,751
28112898956734202515124315749204020865
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
JBIG2Bitmap *getBitmap(Guint idx) { return bitmaps[idx]; }
CWE-189
1,174
11,752
278877336012153560901736130560584523327
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,175
11,753
247690782923801781665061528960380359814
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int JBIG2Stream::getChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr++ ^ 0xff) & 0xff; } return EOF; }
CWE-189
1,176
11,754
253516824912237914791508821243869202836
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
Guchar *getDataPtr() { return data; }
CWE-189
1,177
11,755
211447506254611244651567957742247496995
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int getDataSize() { return h * line; }
CWE-189
1,178
11,756
31963386164957486751007820882374307508
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
JArithmeticDecoderStats *getGenericRegionStats() { return genericRegionStats; }
CWE-189
1,179
11,757
264215465173497922293542013487031330949
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int getHeight() { return h; }
CWE-189
1,180
11,758
208572797998249758202338485191320876781
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
JBIG2HuffmanTable *getHuffTable() { return table; }
CWE-189
1,181
11,759
259002374671954824358078627343055629985
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int getPixel(int x, int y) { return (x < 0 || x >= w || y < 0 || y >= h) ? 0 : (data[y * line + (x >> 3)] >> (7 - (x & 7))) & 1; }
CWE-189
1,183
11,760
153314984519913367846485162729637921081
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
JArithmeticDecoderStats *getRefinementRegionStats() { return refinementRegionStats; }
CWE-189
1,185
11,761
291299583318161264814941972294405488580
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
Guint getSegNum() { return segNum; }
CWE-189
1,186
11,762
117144531650102645654907039377432549952
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
Guint getSize() { return size; }
CWE-189
1,187
11,763
239252592220251771313881304061886153574
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
virtual JBIG2SegmentType getType() { return jbig2SegBitmap; }
CWE-189
1,189
11,764
274304314750792401296427438547394802588
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
virtual JBIG2SegmentType getType() { return jbig2SegSymbolDict; }
CWE-189
1,190
11,765
140365789837889368950228387356604134960
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
virtual JBIG2SegmentType getType() { return jbig2SegPatternDict; }
CWE-189
1,191
11,766
43616451098207432505283882378430339653
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
virtual JBIG2SegmentType getType() { return jbig2SegCodeTable; }
CWE-189
1,192
11,767
203382132353830678199162803984225392742
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,193
11,768
247789652247557659200329643635499355176
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int getWidth() { return w; }
CWE-189
1,194
11,769
307430181913261535642507029554817528983
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GBool JBIG2Stream::isBinary(GBool last) { return str->isBinary(gTrue); }
CWE-189
1,195
11,770
73644504608404326686590725284528437835
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GBool isOk() { return data != NULL; }
CWE-189
1,196
11,771
108658966581385299441895880577172489224
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
int JBIG2Stream::lookChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr ^ 0xff) & 0xff; } return EOF; }
CWE-189
1,197
11,772
124620299537141339849843291010988984419
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
inline int JBIG2Bitmap::nextPixel(JBIG2BitmapPtr *ptr) { int pix; if (!ptr->p) { pix = 0; } else if (ptr->x < 0) { ++ptr->x; pix = 0; } else { pix = (*ptr->p >> ptr->shift) & 1; if (++ptr->x == w) { ptr->p = NULL; } else if (ptr->shift == 0) { ++ptr->p; ptr->shift = 7; } else { --ptr->shift; } } return pix; }
CWE-189
1,198
11,773
176147853223508081792808280721871492268
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
Guint JBIG2HuffmanDecoder::readBit() { if (bufLen == 0) { buf = str->getChar(); bufLen = 8; } --bufLen; return (buf >> bufLen) & 1; }
CWE-189
1,199
11,774
219579880304110913358426154980553377846
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,201
11,775
32463812698252021121105167065702872952
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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"); }
CWE-189
1,202
11,776
143615039114018488444222065915697314867
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void JBIG2Stream::readEndOfStripeSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
CWE-189
1,203
11,777
64500051435459411756995242274637929894
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void JBIG2Stream::readExtensionSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
CWE-189
1,204
11,778
290497113514489838258704578323779855956
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,205
11,779
105622674989151038770142254687512891498
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,206
11,780
202740766697753899668053696953014821272
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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"); }
CWE-189
1,207
11,781
54830886247591989542825292158801528679
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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"); }
CWE-189
1,208
11,782
217547477369688602533543953609281232185
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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"); }
CWE-189
1,209
11,783
321320648015474865188508706813665200505
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,210
11,784
43353721469095979010248951455805805825
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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"); }
CWE-189
1,211
11,785
322099217618344186387322317168597753655
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void JBIG2Stream::readProfilesSeg(Guint length) { Guint i; for (i = 0; i < length; ++i) { curStr->getChar(); } }
CWE-189
1,213
11,786
305818984962005321231275003612563864844
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void JBIG2Stream::readSegments() { Guint segNum, segFlags, segType, page, segLength; Guint refFlags, nRefSegs; Guint *refSegs; int segDataPos; int c1, c2, c3; Guint i; while (readULong(&segNum)) { if (!readUByte(&segFlags)) { goto eofError1; } segType = segFlags & 0x3f; if (!readUByte(&refFlags)) { goto eofError1; } nRefSegs = refFlags >> 5; if (nRefSegs == 7) { if ((c1 = curStr->getChar()) == EOF || (c2 = curStr->getChar()) == EOF || (c3 = curStr->getChar()) == EOF) { goto eofError1; } refFlags = (refFlags << 24) | (c1 << 16) | (c2 << 8) | c3; nRefSegs = refFlags & 0x1fffffff; for (i = 0; i < (nRefSegs + 9) >> 3; ++i) { c1 = curStr->getChar(); } } refSegs = (Guint *)gmallocn(nRefSegs, sizeof(Guint)); if (segNum <= 256) { for (i = 0; i < nRefSegs; ++i) { if (!readUByte(&refSegs[i])) { goto eofError2; } } } else if (segNum <= 65536) { for (i = 0; i < nRefSegs; ++i) { if (!readUWord(&refSegs[i])) { goto eofError2; } } } else { for (i = 0; i < nRefSegs; ++i) { if (!readULong(&refSegs[i])) { goto eofError2; } } } if (segFlags & 0x40) { if (!readULong(&page)) { goto eofError2; } } else { if (!readUByte(&page)) { goto eofError2; } } if (!readULong(&segLength)) { goto eofError2; } segDataPos = getPos(); switch (segType) { case 0: if (!readSymbolDictSeg(segNum, segLength, refSegs, nRefSegs)) { goto syntaxError; } break; case 4: readTextRegionSeg(segNum, gFalse, gFalse, segLength, refSegs, nRefSegs); break; case 6: readTextRegionSeg(segNum, gTrue, gFalse, segLength, refSegs, nRefSegs); break; case 7: readTextRegionSeg(segNum, gTrue, gTrue, segLength, refSegs, nRefSegs); break; case 16: readPatternDictSeg(segNum, segLength); break; case 20: readHalftoneRegionSeg(segNum, gFalse, gFalse, segLength, refSegs, nRefSegs); break; case 22: readHalftoneRegionSeg(segNum, gTrue, gFalse, segLength, refSegs, nRefSegs); break; case 23: readHalftoneRegionSeg(segNum, gTrue, gTrue, segLength, refSegs, nRefSegs); break; case 36: readGenericRegionSeg(segNum, gFalse, gFalse, segLength); break; case 38: readGenericRegionSeg(segNum, gTrue, gFalse, segLength); break; case 39: readGenericRegionSeg(segNum, gTrue, gTrue, segLength); break; case 40: readGenericRefinementRegionSeg(segNum, gFalse, gFalse, segLength, refSegs, nRefSegs); break; case 42: readGenericRefinementRegionSeg(segNum, gTrue, gFalse, segLength, refSegs, nRefSegs); break; case 43: readGenericRefinementRegionSeg(segNum, gTrue, gTrue, segLength, refSegs, nRefSegs); break; case 48: readPageInfoSeg(segLength); break; case 50: readEndOfStripeSeg(segLength); break; case 52: readProfilesSeg(segLength); break; case 53: readCodeTableSeg(segNum, segLength); break; case 62: readExtensionSeg(segLength); break; default: error(getPos(), "Unknown segment type in JBIG2 stream"); for (i = 0; i < segLength; ++i) { if ((c1 = curStr->getChar()) == EOF) { goto eofError2; } } break; } if (segLength != 0xffffffff) { int segExtraBytes = segDataPos + segLength - getPos(); if (segExtraBytes > 0) { error(getPos(), "%d extraneous byte%s after segment", segExtraBytes, (segExtraBytes > 1) ? "s" : ""); int trash; for (int i = segExtraBytes; i > 0; i--) { readByte(&trash); } } else if (segExtraBytes < 0) { error(getPos(), "Previous segment handler read too many bytes"); } } gfree(refSegs); } return; syntaxError: gfree(refSegs); return; eofError2: gfree(refSegs); eofError1: error(getPos(), "Unexpected EOF in JBIG2 stream"); }
CWE-189
1,214
11,787
272988377676655275871760171479217190017
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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(); }
CWE-189
1,215
11,788
48287491240465637526079802165610702520
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,216
11,789
7727802110684111851999967278605999302
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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); }
CWE-189
1,217
11,790
300594182672505692087972931495114981311
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,219
11,791
135663646109449366965846688209080312475
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; } }
CWE-189
1,220
11,792
201221090295005778052951807125467484765
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
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; }
CWE-189
1,221
11,793
60889568329579226872083432712643135735
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void PSOutputDev::clip(GfxState *state) { doPath(state->getPath()); writePS("W\n"); }
CWE-189
1,223
11,794
128087645368471899519897188385070557382
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void PSOutputDev::clipToStrokePath(GfxState *state) { doPath(state->getPath()); writePS("Ws\n"); }
CWE-189
1,224
11,795
85772628117546609305492663911726257307
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,226
11,796
213582906655719613594973605713758611269
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,227
11,797
35020385007897190354177044010452193001
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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]; } }
CWE-189
1,228
11,798
163043926610167760177270514116831788386
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,229
11,799
298221188693200169341185479529979518420
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::clearModRegion() { modXMin = bitmap->getWidth(); modYMin = bitmap->getHeight(); modXMax = -1; modYMax = -1; }
CWE-189
1,231
11,800
15505397397258684512215948898263322792
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::clipResetToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1) { state->clip->resetToRect(x0, y0, x1, y1); }
CWE-189
1,232
11,801
135680312637219558808045064828246540715
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashError Splash::clipToPath(SplashPath *path, GBool eo) { return state->clip->clipToPath(path, state->matrix, state->flatness, eo); }
CWE-189
1,233
11,802
272256100253411615935236065495991903297
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashError Splash::clipToRect(SplashCoord x0, SplashCoord y0, SplashCoord x1, SplashCoord y1) { return state->clip->clipToRect(x0, y0, x1, y1); }
CWE-189
1,234
11,803
107657949004827986235285754845140005233
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,235
11,804
1893886900122198229438483382453250102
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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); } } }
CWE-189
1,237
11,805
48089619393677206530756440998378211074
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
inline void Splash::drawAAPixel(SplashPipe *pipe, int x, 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 }; int w; #else int xx, yy; #endif SplashColorPtr p; int x0, x1, t; if (x < 0 || x >= bitmap->width || y < state->clip->getYMinI() || y > state->clip->getYMaxI()) { return; } if (y != aaBufY) { memset(aaBuf->getDataPtr(), 0xff, aaBuf->getRowSize() * aaBuf->getHeight()); x0 = 0; x1 = bitmap->width - 1; state->clip->clipAALine(aaBuf, &x0, &x1, y); aaBufY = y; } #if splashAASize == 4 p = aaBuf->getDataPtr() + (x >> 1); w = aaBuf->getRowSize(); if (x & 1) { t = bitCount4[*p & 0x0f] + bitCount4[p[w] & 0x0f] + bitCount4[p[2*w] & 0x0f] + bitCount4[p[3*w] & 0x0f]; } else { t = bitCount4[*p >> 4] + bitCount4[p[w] >> 4] + bitCount4[p[2*w] >> 4] + bitCount4[p[3*w] >> 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) { pipeSetXY(pipe, x, y); pipe->shape *= aaGamma[t]; pipeRun(pipe); updateModX(x); updateModY(y); } }
CWE-189
1,238
11,806
130574050427456977051776453991493287707
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
inline void Splash::drawAAPixelInit() { aaBufY = -1; }
CWE-189
1,239
11,807
205106454289664043855581855907477592314
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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); } }
CWE-189
1,240
11,808
122866303693619645034682942467691861129
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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); } } } }
CWE-189
1,241
11,809
33001122571646644940870688451694103742
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::dumpPath(SplashPath *path) { int i; for (i = 0; i < path->length; ++i) { printf(" %3d: x=%8.2f y=%8.2f%s%s%s%s\n", i, (double)path->pts[i].x, (double)path->pts[i].y, (path->flags[i] & splashPathFirst) ? " first" : "", (path->flags[i] & splashPathLast) ? " last" : "", (path->flags[i] & splashPathClosed) ? " closed" : "", (path->flags[i] & splashPathCurve) ? " curve" : ""); } }
CWE-189
1,242
11,810
3437379472541891087829048887277161791
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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" : " "); } }
CWE-189
1,243
11,811
285767969321408288209548436266945935980
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashError Splash::fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font) { SplashGlyphBitmap glyph; SplashCoord xt, yt; int x0, y0, xFrac, yFrac; SplashClipResult clipRes; if (debugMode) { printf("fillChar: x=%.2f y=%.2f c=%3d=0x%02x='%c'\n", (double)x, (double)y, c, c, c); } transform(state->matrix, x, y, &xt, &yt); x0 = splashFloor(xt); xFrac = splashFloor((xt - x0) * splashFontFraction); y0 = splashFloor(yt); yFrac = splashFloor((yt - y0) * splashFontFraction); if (!font->getGlyph(c, xFrac, yFrac, &glyph, x0, y0, state->clip, &clipRes)) { return splashErrNoGlyph; } if (clipRes != splashClipAllOutside) { fillGlyph2(x0, y0, &glyph, clipRes == splashClipAllInside); } opClipRes = clipRes; if (glyph.freeData) { gfree(glyph.data); } return splashOk; }
CWE-189
1,245
11,812
27693676325322121046788132731005412281
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,246
11,813
262083421112313413340654233044826454011
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; } } } }
CWE-189
1,247
11,814
336321841914861661314483794775398481890
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,248
11,815
40298421312332539563644520570860873473
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; } } }
CWE-189
1,249
11,816
96017361021376074269183218900411743405
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,250
11,817
315151884676296697669451538981817821454
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashBlendFunc Splash::getBlendFunc() { return state->blendFunc; }
CWE-189
1,251
11,818
100256187423485741390701480796986988405
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashClip *Splash::getClip() { return state->clip; }
CWE-189
1,252
11,819
23542473232908334248716976838386246972
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashPattern *Splash::getFillPattern() { return state->fillPattern; }
CWE-189
1,254
11,820
270647504193966677069946696026257677752
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord Splash::getFlatness() { return state->flatness; }
CWE-189
1,255
11,821
23954582033373572402481243483052074552
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
GBool Splash::getInNonIsolatedGroup() { return state->inNonIsolatedGroup; }
CWE-189
1,256
11,822
113190721483386963335755670627254620345
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
int Splash::getLineCap() { return state->lineCap; }
CWE-189
1,257
11,823
65961550608007171252289904478213323270
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord *Splash::getLineDash() { return state->lineDash; }
CWE-189
1,258
11,824
163872567066851627705454031808340368835
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
int Splash::getLineDashLength() { return state->lineDashLength; }
CWE-189
1,259
11,825
222465261660221397675961541977131131093
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord Splash::getLineDashPhase() { return state->lineDashPhase; }
CWE-189
1,260
11,826
186521014374465453441041612515044705809
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord Splash::getLineWidth() { return state->lineWidth; }
CWE-189
1,262
11,827
328721993136568319098863739532614942620
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord *Splash::getMatrix() { return state->matrix; }
CWE-189
1,263
11,828
152372382067147137296987877823035691933
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord Splash::getMiterLimit() { return state->miterLimit; }
CWE-189
1,264
11,829
199038869353419703694322134551913668006
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashScreen *Splash::getScreen() { return state->screen; }
CWE-189
1,265
11,830
29763148687419200702133743151269739701
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashBitmap *Splash::getSoftMask() { return state->softMask; }
CWE-189
1,266
11,831
110001633220041395582758995420502535041
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashCoord Splash::getStrokeAlpha() { return state->strokeAlpha; }
CWE-189
1,267
11,832
216908500801377297294846876458316295767
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashPattern *Splash::getStrokePattern() { return state->strokePattern; }
CWE-189
1,268
11,833
206230655246862479439050467707235830381
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
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; }
CWE-189
1,269
11,834
88248060996658962576211802136946450077
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashPath *Splash::makeStrokePath(SplashPath *path, GBool flatten) { SplashPath *pathIn, *pathOut; SplashCoord w, d, dx, dy, wdx, wdy, dxNext, dyNext, wdxNext, wdyNext; SplashCoord crossprod, dotprod, miter, m; GBool first, last, closed; int subpathStart, next, i; int left0, left1, left2, right0, right1, right2, join0, join1, join2; int leftFirst, rightFirst, firstPt; if (flatten) { pathIn = flattenPath(path, state->matrix, state->flatness); if (state->lineDashLength > 0) { pathOut = makeDashedPath(pathIn); delete pathIn; pathIn = pathOut; } } else { pathIn = path; } subpathStart = 0; // make gcc happy closed = gFalse; // make gcc happy left0 = left1 = right0 = right1 = join0 = join1 = 0; // make gcc happy leftFirst = rightFirst = firstPt = 0; // make gcc happy pathOut = new SplashPath(); w = state->lineWidth; for (i = 0; i < pathIn->length - 1; ++i) { if (pathIn->flags[i] & splashPathLast) { continue; } if ((first = pathIn->flags[i] & splashPathFirst)) { subpathStart = i; closed = pathIn->flags[i] & splashPathClosed; } last = pathIn->flags[i+1] & splashPathLast; d = splashDist(pathIn->pts[i].x, pathIn->pts[i].y, pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (d == 0) { dx = 0; dy = 1; } else { d = (SplashCoord)1 / d; dx = d * (pathIn->pts[i+1].x - pathIn->pts[i].x); dy = d * (pathIn->pts[i+1].y - pathIn->pts[i].y); } wdx = (SplashCoord)0.5 * w * dx; wdy = (SplashCoord)0.5 * w * dy; next = last ? subpathStart + 1 : i + 2; d = splashDist(pathIn->pts[i+1].x, pathIn->pts[i+1].y, pathIn->pts[next].x, pathIn->pts[next].y); if (d == 0) { dxNext = 0; dyNext = 1; } else { d = (SplashCoord)1 / d; dxNext = d * (pathIn->pts[next].x - pathIn->pts[i+1].x); dyNext = d * (pathIn->pts[next].y - pathIn->pts[i+1].y); } wdxNext = (SplashCoord)0.5 * w * dxNext; wdyNext = (SplashCoord)0.5 * w * dyNext; pathOut->moveTo(pathIn->pts[i].x - wdy, pathIn->pts[i].y + wdx); if (i == subpathStart) { firstPt = pathOut->length - 1; } if (first && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i].x - wdy - bezierCircle * wdx, pathIn->pts[i].y + wdx - bezierCircle * wdy, pathIn->pts[i].x - wdx - bezierCircle * wdy, pathIn->pts[i].y - wdy + bezierCircle * wdx, pathIn->pts[i].x - wdx, pathIn->pts[i].y - wdy); pathOut->curveTo(pathIn->pts[i].x - wdx + bezierCircle * wdy, pathIn->pts[i].y - wdy - bezierCircle * wdx, pathIn->pts[i].x + wdy - bezierCircle * wdx, pathIn->pts[i].y - wdx - bezierCircle * wdy, pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i].x - wdx - wdy, pathIn->pts[i].y + wdx - wdy); pathOut->lineTo(pathIn->pts[i].x - wdx + wdy, pathIn->pts[i].y - wdx - wdy); pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; } } else { pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); } left2 = pathOut->length - 1; pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (last && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i+1].x + wdy + bezierCircle * wdx, pathIn->pts[i+1].y - wdx + bezierCircle * wdy, pathIn->pts[i+1].x + wdx + bezierCircle * wdy, pathIn->pts[i+1].y + wdy - bezierCircle * wdx, pathIn->pts[i+1].x + wdx, pathIn->pts[i+1].y + wdy); pathOut->curveTo(pathIn->pts[i+1].x + wdx - bezierCircle * wdy, pathIn->pts[i+1].y + wdy + bezierCircle * wdx, pathIn->pts[i+1].x - wdy + bezierCircle * wdx, pathIn->pts[i+1].y + wdx + bezierCircle * wdy, pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx, pathIn->pts[i+1].y - wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx, pathIn->pts[i+1].y + wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; } } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } right2 = pathOut->length - 1; pathOut->close(); join2 = pathOut->length; if (!last || closed) { crossprod = dx * dyNext - dy * dxNext; dotprod = -(dx * dxNext + dy * dyNext); if (dotprod > 0.99999) { miter = (state->miterLimit + 1) * (state->miterLimit + 1); m = 0; } else { miter = (SplashCoord)2 / ((SplashCoord)1 - dotprod); if (miter < 1) { miter = 1; } m = splashSqrt(miter - 1); } if (state->lineJoin == splashLineJoinRound) { pathOut->moveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y + (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y - (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); } else { pathOut->moveTo(pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (crossprod < 0) { pathOut->lineTo(pathIn->pts[i+1].x - wdyNext, pathIn->pts[i+1].y + wdxNext); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx * m, pathIn->pts[i+1].y + wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } } else { pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx * m, pathIn->pts[i+1].y - wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } else { pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } } } pathOut->close(); } if (state->strokeAdjust) { if (i >= subpathStart + 1) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, left2); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2); } pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1); } left0 = left1; left1 = left2; right0 = right1; right1 = right2; join0 = join1; join1 = join2; if (i == subpathStart) { leftFirst = left2; rightFirst = right2; } if (last) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, pathOut->length - 1); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, pathOut->length - 1); } if (closed) { pathOut->addStrokeAdjustHint(left1, right1, firstPt, leftFirst); pathOut->addStrokeAdjustHint(left1, right1, rightFirst + 1, rightFirst + 1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, left1 + 1, right1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, join1, pathOut->length - 1); } } } } if (pathIn != path) { delete pathIn; } return pathOut; }
CWE-189
1,270
11,835
86000409344513745205606786493798329314
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
inline void Splash::pipeIncX(SplashPipe *pipe) { ++pipe->x; if (state->softMask) { ++pipe->softMaskPtr; } switch (bitmap->mode) { case splashModeMono1: if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: ++pipe->destColorPtr; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr += 3; break; case splashModeXBGR8: pipe->destColorPtr += 4; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr += 4; break; #endif } if (pipe->destAlphaPtr) { ++pipe->destAlphaPtr; } if (pipe->alpha0Ptr) { ++pipe->alpha0Ptr; } }
CWE-189
1,271
11,836
14296923385789374840902852863343231090
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, SplashPattern *pattern, SplashColorPtr cSrc, SplashCoord aInput, GBool usesShape, GBool nonIsolatedGroup) { pipeSetXY(pipe, x, y); pipe->pattern = NULL; if (pattern) { if (pattern->isStatic()) { pattern->getColor(x, y, pipe->cSrcVal); } else { pipe->pattern = pattern; } pipe->cSrc = pipe->cSrcVal; } else { pipe->cSrc = cSrc; } pipe->aInput = aInput; if (!state->softMask) { if (usesShape) { pipe->aInput *= 255; } else { pipe->aSrc = (Guchar)splashRound(pipe->aInput * 255); } } pipe->usesShape = usesShape; if (aInput == 1 && !state->softMask && !usesShape && !state->inNonIsolatedGroup) { pipe->noTransparency = gTrue; } else { pipe->noTransparency = gFalse; } if (pipe->noTransparency) { pipe->resultColorCtrl = pipeResultColorNoAlphaBlend[bitmap->mode]; } else if (!state->blendFunc) { pipe->resultColorCtrl = pipeResultColorAlphaNoBlend[bitmap->mode]; } else { pipe->resultColorCtrl = pipeResultColorAlphaBlend[bitmap->mode]; } if (nonIsolatedGroup) { pipe->nonIsolatedGroup = splashColorModeNComps[bitmap->mode]; } else { pipe->nonIsolatedGroup = 0; } }
CWE-189
1,272
11,837
159922125480731897468539441576044249227
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) { pipe->x = x; pipe->y = y; if (state->softMask) { pipe->softMaskPtr = &state->softMask->data[y * state->softMask->rowSize + x]; } switch (bitmap->mode) { case splashModeMono1: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (x >> 3)]; pipe->destColorMask = 0x80 >> (x & 7); break; case splashModeMono8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + x]; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 3 * x]; break; case splashModeXBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #endif } if (bitmap->alpha) { pipe->destAlphaPtr = &bitmap->alpha[y * bitmap->width + x]; } else { pipe->destAlphaPtr = NULL; } if (state->inNonIsolatedGroup && alpha0Bitmap->alpha) { pipe->alpha0Ptr = &alpha0Bitmap->alpha[(alpha0Y + y) * alpha0Bitmap->width + (alpha0X + x)]; } else { pipe->alpha0Ptr = NULL; } }
CWE-189
1,274
11,838
36373996578061240341157947952666684814
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
SplashError Splash::restoreState() { SplashState *oldState; if (!state->next) { return splashErrNoSave; } oldState = state; state = state->next; delete oldState; return splashOk; }
CWE-189
1,275
11,839
191945892238815877067115889769456949086
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::saveState() { SplashState *newState; newState = state->copy(); newState->next = state; state = newState; }
CWE-189
1,276
11,840
31886546540723918132218346573610001971
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setBlendFunc(SplashBlendFunc func) { state->blendFunc = func; }
CWE-189
1,277
11,841
147471288843710391476435435656088159394
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setFillAlpha(SplashCoord alpha) { state->fillAlpha = alpha; }
CWE-189
1,278
11,842
301800440859542904118510717257788938366
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setFlatness(SplashCoord flatness) { if (flatness < 1) { state->flatness = 1; } else { state->flatness = flatness; } }
CWE-189
1,279
11,843
165131756379540395274411141144938834870
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, int alpha0XA, int alpha0YA) { alpha0Bitmap = alpha0BitmapA; alpha0X = alpha0XA; alpha0Y = alpha0YA; state->inNonIsolatedGroup = gTrue; }
CWE-189
1,280
11,844
153802814772855319419082435555672717824
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setLineCap(int lineCap) { state->lineCap = lineCap; }
CWE-189
1,281
11,845
230265990436766085008870345688687085988
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setLineDash(SplashCoord *lineDash, int lineDashLength, SplashCoord lineDashPhase) { state->setLineDash(lineDash, lineDashLength, lineDashPhase); }
CWE-189
1,282
11,846
75164341005425024164782797525424213917
null
null
null
poppler
9cf2325fb22f812b31858e519411f57747d39bd8
0
void Splash::setLineWidth(SplashCoord lineWidth) { state->lineWidth = lineWidth; }
CWE-189
1,284
11,847
132538238172379570754040707663609491992
null
null
null