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
284a92899602daa4a7f429e61849e794569310b5
0
static void cvtHSVToRGB(int h, int s, int v, Guchar *r, Guchar *g, Guchar *b) { int x, f, cmax, cmid, cmin; if (s == 0) { *r = *g = *b = v; } else { x = h / 60; f = h % 60; cmax = v; if (x & 1) { cmid = div255(v * 255 - ((s * f) / 60)); } else { cmid = div255(v * (255 - ((s * (60 - f)) / 60))); } cmin = div255(v * (255 - s)); switch (x) { case 0: *r = cmax; *g = cmid; *b = cmin; break; case 1: *g = cmax; *r = cmid; *b = cmin; break; case 2: *g = cmax; *b = cmid; *r = cmin; break; case 3: *b = cmax; *g = cmid; *r = cmin; break; case 4: *b = cmax; *r = cmid; *g = cmin; break; case 5: *r = cmax; *b = cmid; *g = cmin; break; } } }
CWE-189
827
11,448
222999498007532113927835515478445722092
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
static void cvtRGBToHSV(Guchar r, Guchar g, Guchar b, int *h, int *s, int *v) { int cmax, cmid, cmin, x; if (r >= g) { if (g >= b) { x = 0; cmax = r; cmid = g; cmin = b; } else if (b >= r) { x = 4; cmax = b; cmid = r; cmin = g; } else { x = 5; cmax = r; cmid = b; cmin = g; } } else { if (r >= b) { x = 1; cmax = g; cmid = r; cmin = b; } else if (g >= b) { x = 2; cmax = g; cmid = b; cmin = r; } else { x = 3; cmax = b; cmid = g; cmin = r; } } if (cmax == cmin) { *h = *s = 0; } else { *h = x * 60; if (x & 1) { *h += ((cmax - cmid) * 60) / (cmax - cmin); } else { *h += ((cmid - cmin) * 60) / (cmax - cmin); } *s = (255 * (cmax - cmin)) / cmax; } *v = cmax; }
CWE-189
828
11,449
316396768075084326321996919196575277334
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
static inline Guchar div255(int x) { return (Guchar)((x + (x >> 8) + 0x80) >> 8); }
CWE-189
829
11,450
175089354021511089320379298610923172958
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::doUpdateFont(GfxState *state) { GfxFont *gfxFont; GfxFontType fontType; SplashOutFontFileID *id; SplashFontFile *fontFile; SplashFontSrc *fontsrc = NULL; FoFiTrueType *ff; Ref embRef; Object refObj, strObj; GooString *fileName; char *tmpBuf; int tmpBufLen; Gushort *codeToGID; DisplayFontParam *dfp; double *textMat; double m11, m12, m21, m22, fontSize; SplashCoord mat[4]; int substIdx, n; int faceIndex = 0; GBool recreateFont = gFalse; GBool doAdjustFontMatrix = gFalse; needFontUpdate = gFalse; font = NULL; fileName = NULL; tmpBuf = NULL; substIdx = -1; dfp = NULL; if (!(gfxFont = state->getFont())) { goto err1; } fontType = gfxFont->getType(); if (fontType == fontType3) { goto err1; } id = new SplashOutFontFileID(gfxFont->getID()); if ((fontFile = fontEngine->getFontFile(id))) { delete id; } else { if (gfxFont->getEmbeddedFontID(&embRef)) { tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); if (! tmpBuf) goto err2; } else if (!(fileName = gfxFont->getExtFontFile())) { dfp = NULL; if (gfxFont->getName()) { dfp = globalParams->getDisplayFont(gfxFont); } if (!dfp) { error(-1, "Couldn't find a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } switch (dfp->kind) { case displayFontT1: fileName = dfp->t1.fileName; fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1; break; case displayFontTT: fileName = dfp->tt.fileName; fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType; faceIndex = dfp->tt.faceIndex; break; } doAdjustFontMatrix = gTrue; } fontsrc = new SplashFontSrc; if (fileName) fontsrc->setFile(fileName, gFalse); else fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue); switch (fontType) { case fontType1: if (!(fontFile = fontEngine->loadType1Font( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1C: if (!(fontFile = fontEngine->loadType1CFont( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1COT: if (!(fontFile = fontEngine->loadOpenTypeT1CFont( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontTrueType: case fontTrueTypeOT: if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (ff) { codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); n = 256; delete ff; } else { codeToGID = NULL; n = 0; } if (!(fontFile = fontEngine->loadTrueTypeFont( id, fontsrc, codeToGID, n))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType0: case fontCIDType0C: if (!(fontFile = fontEngine->loadCIDFont( id, fontsrc))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType0COT: if (!(fontFile = fontEngine->loadOpenTypeCFFFont( id, fontsrc))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType2: case fontCIDType2OT: codeToGID = NULL; n = 0; if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); if (n) { codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), n * sizeof(Gushort)); } } else { if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (! ff) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); delete ff; } if (!(fontFile = fontEngine->loadTrueTypeFont( id, fontsrc, codeToGID, n, faceIndex))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; default: goto err2; } fontFile->doAdjustMatrix = doAdjustFontMatrix; } textMat = state->getTextMat(); fontSize = state->getFontSize(); m11 = textMat[0] * fontSize * state->getHorizScaling(); m12 = textMat[1] * fontSize * state->getHorizScaling(); m21 = textMat[2] * fontSize; m22 = textMat[3] * fontSize; mat[0] = m11; mat[1] = m12; mat[2] = m21; mat[3] = m22; font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); if (fontFile->doAdjustMatrix && !gfxFont->isCIDFont()) { double w1, w2; CharCode code; char *name; for (code = 0; code < 256; ++code) { if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) && name[0] == 'm' && name[1] == '\0') { break; } } if (code < 256) { w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code); w2 = font->getGlyphAdvance(code); if (!gfxFont->isSymbolic() && w2 > 0) { if (w1 > 0.01 && w1 < 0.9 * w2) { w1 /= w2; m11 *= w1; m21 *= w1; recreateFont = gTrue; } } } } if (recreateFont) { mat[0] = m11; mat[1] = m12; mat[2] = m21; mat[3] = m22; font = fontEngine->getFont(fontFile, mat, splash->getMatrix()); } if (fontsrc && !fontsrc->isFile) fontsrc->unref(); return; err2: delete id; err1: if (fontsrc && !fontsrc->isFile) fontsrc->unref(); return; }
CWE-189
830
11,451
263845450473647750334947814246072153036
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode *u, int uLen) { SplashPath *path; int render; render = state->getRender(); if (render == 3) { return; } if (needFontUpdate) { doUpdateFont(state); } if (!font) { return; } x -= originX; y -= originY; if (!(render & 1)) { if (!state->getFillColorSpace()->isNonMarking()) { splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font); } } if ((render & 3) == 1 || (render & 3) == 2) { if (!state->getStrokeColorSpace()->isNonMarking()) { if ((path = font->getGlyphPath(code))) { path->offset((SplashCoord)x, (SplashCoord)y); splash->stroke(path); delete path; } } } if (render & 4) { if ((path = font->getGlyphPath(code))) { path->offset((SplashCoord)x, (SplashCoord)y); if (textClipPath) { textClipPath->append(path); delete path; } else { textClipPath = path; } } } }
CWE-189
831
11,452
87964604733333236365964102781158175003
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { double *ctm; SplashCoord mat[6]; SplashOutImageMaskData imgMaskData; if (state->getFillColorSpace()->isNonMarking()) { return; } ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; imgMaskData.imgStr = new ImageStream(str, width, 1, 1); imgMaskData.imgStr->reset(); imgMaskData.invert = invert ? 0 : 1; imgMaskData.width = width; imgMaskData.height = height; imgMaskData.y = 0; splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL); if (inlineImg) { while (imgMaskData.y < height) { imgMaskData.imgStr->getLine(); ++imgMaskData.y; } } delete imgMaskData.imgStr; str->close(); }
CWE-189
832
11,453
2322660216613038215730865939659133331
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { GfxImageColorMap *maskColorMap; Object maskDecode, decodeLow, decodeHigh; double *ctm; SplashCoord mat[6]; SplashOutMaskedImageData imgData; SplashOutImageMaskData imgMaskData; SplashColorMode srcMode; SplashBitmap *maskBitmap; Splash *maskSplash; SplashColor maskColor; GfxGray gray; GfxRGB rgb; #if SPLASH_CMYK GfxCMYK cmyk; #endif Guchar pix; int n, i; if (maskWidth > width || maskHeight > height) { decodeLow.initInt(maskInvert ? 0 : 1); decodeHigh.initInt(maskInvert ? 1 : 0); maskDecode.initArray(xref); maskDecode.arrayAdd(&decodeLow); maskDecode.arrayAdd(&decodeHigh); maskColorMap = new GfxImageColorMap(1, &maskDecode, new GfxDeviceGrayColorSpace()); maskDecode.free(); drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); delete maskColorMap; } else { mat[0] = (SplashCoord)width; mat[1] = 0; mat[2] = 0; mat[3] = (SplashCoord)height; mat[4] = 0; mat[5] = 0; imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1); imgMaskData.imgStr->reset(); imgMaskData.invert = maskInvert ? 0 : 1; imgMaskData.width = maskWidth; imgMaskData.height = maskHeight; imgMaskData.y = 0; maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, gFalse); maskSplash = new Splash(maskBitmap, gFalse); maskColor[0] = 0; maskSplash->clear(maskColor); maskColor[0] = 0xff; maskSplash->setFillPattern(new SplashSolidColor(maskColor)); maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData, maskWidth, maskHeight, mat, gFalse); delete imgMaskData.imgStr; maskStr->close(); delete maskSplash; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; imgData.imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits()); imgData.imgStr->reset(); imgData.colorMap = colorMap; imgData.mask = maskBitmap; imgData.colorMode = colorMode; imgData.width = width; imgData.height = height; imgData.y = 0; imgData.lookup = NULL; if (colorMap->getNumPixelComps() == 1) { n = 1 << colorMap->getBits(); switch (colorMode) { case splashModeMono1: case splashModeMono8: imgData.lookup = (SplashColorPtr)gmalloc(n); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getGray(&pix, &gray); imgData.lookup[i] = colToByte(gray); } break; case splashModeRGB8: case splashModeBGR8: imgData.lookup = (SplashColorPtr)gmallocn(n, 3); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getRGB(&pix, &rgb); imgData.lookup[3*i] = colToByte(rgb.r); imgData.lookup[3*i+1] = colToByte(rgb.g); imgData.lookup[3*i+2] = colToByte(rgb.b); } break; case splashModeXBGR8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getRGB(&pix, &rgb); imgData.lookup[4*i] = colToByte(rgb.r); imgData.lookup[4*i+1] = colToByte(rgb.g); imgData.lookup[4*i+2] = colToByte(rgb.b); imgData.lookup[4*i+3] = 255; } break; #if SPLASH_CMYK case splashModeCMYK8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getCMYK(&pix, &cmyk); imgData.lookup[4*i] = colToByte(cmyk.c); imgData.lookup[4*i+1] = colToByte(cmyk.m); imgData.lookup[4*i+2] = colToByte(cmyk.y); imgData.lookup[4*i+3] = colToByte(cmyk.k); } break; #endif } } if (colorMode == splashModeMono1) { srcMode = splashModeMono8; } else { srcMode = colorMode; } splash->drawImage(&maskedImageSrc, &imgData, srcMode, gTrue, width, height, mat); delete maskBitmap; gfree(imgData.lookup); delete imgData.imgStr; str->close(); } }
CWE-189
833
11,454
76198281133951422846487684214926972560
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap) { double *ctm; SplashCoord mat[6]; SplashOutImageData imgData; SplashOutImageData imgMaskData; SplashColorMode srcMode; SplashBitmap *maskBitmap; Splash *maskSplash; SplashColor maskColor; GfxGray gray; GfxRGB rgb; #if SPLASH_CMYK GfxCMYK cmyk; #endif Guchar pix; int n, i; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, maskColorMap->getNumPixelComps(), maskColorMap->getBits()); imgMaskData.imgStr->reset(); imgMaskData.colorMap = maskColorMap; imgMaskData.maskColors = NULL; imgMaskData.colorMode = splashModeMono8; imgMaskData.width = maskWidth; imgMaskData.height = maskHeight; imgMaskData.y = 0; n = 1 << maskColorMap->getBits(); imgMaskData.lookup = (SplashColorPtr)gmalloc(n); for (i = 0; i < n; ++i) { pix = (Guchar)i; maskColorMap->getGray(&pix, &gray); imgMaskData.lookup[i] = colToByte(gray); } maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(), 1, splashModeMono8, gFalse); maskSplash = new Splash(maskBitmap, vectorAntialias); maskColor[0] = 0; maskSplash->clear(maskColor); maskSplash->drawImage(&imageSrc, &imgMaskData, splashModeMono8, gFalse, maskWidth, maskHeight, mat); delete imgMaskData.imgStr; maskStr->close(); gfree(imgMaskData.lookup); delete maskSplash; splash->setSoftMask(maskBitmap); imgData.imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits()); imgData.imgStr->reset(); imgData.colorMap = colorMap; imgData.maskColors = NULL; imgData.colorMode = colorMode; imgData.width = width; imgData.height = height; imgData.y = 0; imgData.lookup = NULL; if (colorMap->getNumPixelComps() == 1) { n = 1 << colorMap->getBits(); switch (colorMode) { case splashModeMono1: case splashModeMono8: imgData.lookup = (SplashColorPtr)gmalloc(n); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getGray(&pix, &gray); imgData.lookup[i] = colToByte(gray); } break; case splashModeRGB8: case splashModeBGR8: imgData.lookup = (SplashColorPtr)gmallocn(n, 3); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getRGB(&pix, &rgb); imgData.lookup[3*i] = colToByte(rgb.r); imgData.lookup[3*i+1] = colToByte(rgb.g); imgData.lookup[3*i+2] = colToByte(rgb.b); } break; case splashModeXBGR8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getRGB(&pix, &rgb); imgData.lookup[4*i] = colToByte(rgb.r); imgData.lookup[4*i+1] = colToByte(rgb.g); imgData.lookup[4*i+2] = colToByte(rgb.b); imgData.lookup[4*i+3] = 255; } break; #if SPLASH_CMYK case splashModeCMYK8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { pix = (Guchar)i; colorMap->getCMYK(&pix, &cmyk); imgData.lookup[4*i] = colToByte(cmyk.c); imgData.lookup[4*i+1] = colToByte(cmyk.m); imgData.lookup[4*i+2] = colToByte(cmyk.y); imgData.lookup[4*i+3] = colToByte(cmyk.k); } break; #endif } } if (colorMode == splashModeMono1) { srcMode = splashModeMono8; } else { srcMode = colorMode; } splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat); splash->setSoftMask(NULL); gfree(imgData.lookup); delete imgData.imgStr; str->close(); }
CWE-189
834
11,455
35557390161196930748414561638129789405
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::drawType3Glyph(T3FontCache *t3Font, T3FontCacheTag * /*tag*/, Guchar *data) { SplashGlyphBitmap glyph; glyph.x = -t3Font->glyphX; glyph.y = -t3Font->glyphY; glyph.w = t3Font->glyphW; glyph.h = t3Font->glyphH; glyph.aa = colorMode != splashModeMono1; glyph.data = data; glyph.freeData = gFalse; splash->fillGlyph(0, 0, &glyph); }
CWE-189
835
11,456
270089929435727486051161781485606794801
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::endPage() { if (colorMode != splashModeMono1) { splash->compositeBackground(paperColor); } }
CWE-189
836
11,457
228848162641592598544800672183493413980
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::endTextObject(GfxState *state) { if (textClipPath) { splash->clipToPath(textClipPath, gFalse); delete textClipPath; textClipPath = NULL; } }
CWE-189
837
11,458
116626406059347182585653621150539047212
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::endTransparencyGroup(GfxState *state) { double *ctm; delete splash; bitmap = transpGroupStack->origBitmap; splash = transpGroupStack->origSplash; ctm = state->getCTM(); state->shiftCTM(transpGroupStack->tx, transpGroupStack->ty); updateCTM(state, 0, 0, 0, 0, 0, 0); }
CWE-189
838
11,459
238086720751719402964257858399992980981
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::endType3Char(GfxState *state) { T3GlyphStack *t3gs; double *ctm; if (t3GlyphStack->cacheTag) { memcpy(t3GlyphStack->cacheData, bitmap->getDataPtr(), t3GlyphStack->cache->glyphSize); delete bitmap; delete splash; bitmap = t3GlyphStack->origBitmap; splash = t3GlyphStack->origSplash; ctm = state->getCTM(); state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], t3GlyphStack->origCTM4, t3GlyphStack->origCTM5); updateCTM(state, 0, 0, 0, 0, 0, 0); drawType3Glyph(t3GlyphStack->cache, t3GlyphStack->cacheTag, t3GlyphStack->cacheData); } t3gs = t3GlyphStack; t3GlyphStack = t3gs->next; delete t3gs; }
CWE-189
839
11,460
75880658533715624051809050134541022303
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::eoClip(GfxState *state) { SplashPath *path; path = convertPath(state, state->getPath()); splash->clipToPath(path, gTrue); delete path; }
CWE-189
840
11,461
312464993414015411803751412850196515021
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
int SplashOutputDev::getBitmapWidth() { return bitmap->getWidth(); }
CWE-189
843
11,462
169806139049303476717168805129422344964
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
ArthurOutputDev::ArthurOutputDev(QPainter *painter): m_painter(painter) { m_currentBrush = QBrush(Qt::SolidPattern); m_fontEngine = 0; m_font = 0; m_image = 0; }
CWE-189
844
11,463
98206034402637479490684757512768751344
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GBool ArthurOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen) { return gFalse; }
CWE-189
845
11,464
275691258129609323580142998758238062583
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::clip(GfxState *state) { m_painter->setClipPath(convertPath( state, state->getPath(), Qt::WindingFill ) ); }
CWE-189
846
11,465
297433892713984784680556305758651335159
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static QPainterPath convertPath(GfxState *state, GfxPath *path, Qt::FillRule fillRule) { GfxSubpath *subpath; double x1, y1, x2, y2, x3, y3; int i, j; QPainterPath qPath; qPath.setFillRule(fillRule); for (i = 0; i < path->getNumSubpaths(); ++i) { subpath = path->getSubpath(i); if (subpath->getNumPoints() > 0) { state->transform(subpath->getX(0), subpath->getY(0), &x1, &y1); qPath.moveTo(x1, y1); j = 1; while (j < subpath->getNumPoints()) { if (subpath->getCurve(j)) { state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1); state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2); state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3); qPath.cubicTo( x1, y1, x2, y2, x3, y3); j += 3; } else { state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1); qPath.lineTo(x1, y1); ++j; } } if (subpath->isClosed()) { qPath.closeSubpath(); } } } return qPath; }
CWE-189
847
11,466
99257303800336122780434846495525416827
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { qDebug() << "drawImageMask"; #if 0 unsigned char *buffer; unsigned char *dest; cairo_surface_t *image; cairo_pattern_t *pattern; int x, y; ImageStream *imgStr; Guchar *pix; double *ctm; cairo_matrix_t matrix; int invert_bit; int row_stride; row_stride = (width + 3) & ~3; buffer = (unsigned char *) malloc (height * row_stride); if (buffer == NULL) { error(-1, "Unable to allocate memory for image."); return; } /* TODO: Do we want to cache these? */ imgStr = new ImageStream(str, width, 1, 1); imgStr->reset(); invert_bit = invert ? 1 : 0; for (y = 0; y < height; y++) { pix = imgStr->getLine(); dest = buffer + y * row_stride; for (x = 0; x < width; x++) { if (pix[x] ^ invert_bit) *dest++ = 0; else *dest++ = 255; } } image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8, width, height, row_stride); if (image == NULL) return; pattern = cairo_pattern_create_for_surface (image); if (pattern == NULL) return; ctm = state->getCTM(); LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); matrix.xx = ctm[0] / width; matrix.xy = -ctm[2] / height; matrix.yx = ctm[1] / width; matrix.yy = -ctm[3] / height; matrix.x0 = ctm[2] + ctm[4]; matrix.y0 = ctm[3] + ctm[5]; cairo_matrix_invert (&matrix); cairo_pattern_set_matrix (pattern, &matrix); cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST); /* FIXME: Doesn't the image mask support any colorspace? */ cairo_set_source_rgb (cairo, fill_color.r, fill_color.g, fill_color.b); cairo_mask (cairo, pattern); cairo_pattern_destroy (pattern); cairo_surface_destroy (image); free (buffer); delete imgStr; #endif }
CWE-189
848
11,467
11220656496222326085251238571072675239
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::drawLink(Link *link, Catalog *catalog) { }
CWE-189
849
11,468
205835839740258034442336665583300037468
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::endPage() { }
CWE-189
850
11,469
266814266723395654169517158013480952774
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::endTextObject(GfxState *state) { }
CWE-189
851
11,470
43556466471305710605129984679302179279
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::endType3Char(GfxState *state) { }
CWE-189
852
11,471
245770399196006608725175787253662636179
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::eoFill(GfxState *state) { m_painter->fillPath( convertPath( state, state->getPath(), Qt::OddEvenFill ), m_currentBrush ); }
CWE-189
854
11,472
135652526724502594602972329198527791294
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::fill(GfxState *state) { m_painter->fillPath( convertPath( state, state->getPath(), Qt::WindingFill ), m_currentBrush ); }
CWE-189
855
11,473
57593469972893218492690411705049634257
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GBool matches(SplashFontFileID *id) { return ((SplashOutFontFileID *)id)->r.num == r.num && ((SplashOutFontFileID *)id)->r.gen == r.gen; }
CWE-189
856
11,474
133630056042479224131652184980667325605
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::restoreState(GfxState *state) { m_painter->restore(); }
CWE-189
857
11,475
67311972179804682294383063167146124166
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::saveState(GfxState *state) { m_painter->save(); }
CWE-189
858
11,476
11585143732675145487073405943101934709
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::startDoc(XRef *xrefA) { xref = xrefA; delete m_fontEngine; m_fontEngine = new SplashFontEngine( #if HAVE_T1LIB_H globalParams->getEnableT1lib(), #endif #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H globalParams->getEnableFreeType(), #endif m_painter->testRenderHint(QPainter::TextAntialiasing)); }
CWE-189
859
11,477
167015193247555306372785588577471217123
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::type3D0(GfxState *state, double wx, double wy) { }
CWE-189
862
11,478
161451763061566594601875428817954620065
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { }
CWE-189
863
11,479
225474219816107781416716299425735377240
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) { updateLineDash(state); updateLineJoin(state); updateLineCap(state); updateLineWidth(state); }
CWE-189
865
11,480
232445538706659979727137186213497068732
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateFillColor(GfxState *state) { GfxRGB rgb; QColor brushColour = m_currentBrush.color(); state->getFillRGB(&rgb); brushColour.setRgbF(colToDbl(rgb.r), colToDbl(rgb.g), colToDbl(rgb.b), brushColour.alphaF()); m_currentBrush.setColor(brushColour); }
CWE-189
866
11,481
131428232051994146605133977374568808883
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateFillOpacity(GfxState *state) { QColor brushColour= m_currentBrush.color(); brushColour.setAlphaF(state->getFillOpacity()); m_currentBrush.setColor(brushColour); }
CWE-189
867
11,482
163837346923643047713378484253735856106
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateFlatness(GfxState *state) { }
CWE-189
868
11,483
235792632429501760335642326126433223956
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateFont(GfxState *state) { GfxFont *gfxFont; GfxFontType fontType; SplashOutFontFileID *id; SplashFontFile *fontFile; SplashFontSrc *fontsrc; FoFiTrueType *ff; Ref embRef; Object refObj, strObj; GooString *fileName; char *tmpBuf; int tmpBufLen; Gushort *codeToGID; DisplayFontParam *dfp; double *textMat; double m11, m12, m21, m22, fontSize; SplashCoord mat[4]; int substIdx, n; int faceIndex = 0; SplashCoord matrix[6]; m_needFontUpdate = false; m_font = NULL; fileName = NULL; tmpBuf = NULL; substIdx = -1; if (!(gfxFont = state->getFont())) { goto err1; } fontType = gfxFont->getType(); if (fontType == fontType3) { goto err1; } id = new SplashOutFontFileID(gfxFont->getID()); if ((fontFile = m_fontEngine->getFontFile(id))) { delete id; } else { if (gfxFont->getEmbeddedFontID(&embRef)) { tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); if (! tmpBuf) goto err2; } else if (!(fileName = gfxFont->getExtFontFile())) { dfp = NULL; if (gfxFont->getName()) { dfp = globalParams->getDisplayFont(gfxFont); } if (!dfp) { error(-1, "Couldn't find a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } switch (dfp->kind) { case displayFontT1: fileName = dfp->t1.fileName; fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1; break; case displayFontTT: fileName = dfp->tt.fileName; fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType; faceIndex = dfp->tt.faceIndex; break; } } fontsrc = new SplashFontSrc; if (fileName) fontsrc->setFile(fileName, gFalse); else fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse); switch (fontType) { case fontType1: if (!(fontFile = m_fontEngine->loadType1Font( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1C: if (!(fontFile = m_fontEngine->loadType1CFont( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1COT: if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont( id, fontsrc, ((Gfx8BitFont *)gfxFont)->getEncoding()))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontTrueType: case fontTrueTypeOT: if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (ff) { codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); n = 256; delete ff; } else { codeToGID = NULL; n = 0; } if (!(fontFile = m_fontEngine->loadTrueTypeFont( id, fontsrc, codeToGID, n))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType0: case fontCIDType0C: if (!(fontFile = m_fontEngine->loadCIDFont( id, fontsrc))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType0COT: if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( id, fontsrc))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType2: case fontCIDType2OT: codeToGID = NULL; n = 0; if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); if (n) { codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), n * sizeof(Gushort)); } } else { if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (! ff) goto err2; codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); delete ff; } if (!(fontFile = m_fontEngine->loadTrueTypeFont( id, fontsrc, codeToGID, n, faceIndex))) { error(-1, "Couldn't create a font for '%s'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; default: goto err2; } } textMat = state->getTextMat(); fontSize = state->getFontSize(); m11 = textMat[0] * fontSize * state->getHorizScaling(); m12 = textMat[1] * fontSize * state->getHorizScaling(); m21 = textMat[2] * fontSize; m22 = textMat[3] * fontSize; { QMatrix painterMatrix = m_painter->worldMatrix(); matrix[0] = painterMatrix.m11(); matrix[1] = painterMatrix.m12(); matrix[2] = painterMatrix.m21(); matrix[3] = painterMatrix.m22(); matrix[4] = painterMatrix.dx(); matrix[5] = painterMatrix.dy(); } mat[0] = m11; mat[1] = -m12; mat[2] = m21; mat[3] = -m22; m_font = m_fontEngine->getFont(fontFile, mat, matrix); return; err2: delete id; err1: return; }
CWE-189
869
11,484
99478256679471913587913092190422598799
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateLineCap(GfxState *state) { switch (state->getLineCap()) { case 0: m_currentPen.setCapStyle(Qt::FlatCap); break; case 1: m_currentPen.setCapStyle(Qt::RoundCap); break; case 2: m_currentPen.setCapStyle(Qt::SquareCap); break; } m_painter->setPen(m_currentPen); }
CWE-189
870
11,485
269725718310195671331030824048636070019
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateLineDash(GfxState *state) { }
CWE-189
871
11,486
158636350966687291572691455518590109785
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateLineWidth(GfxState *state) { m_currentPen.setWidthF(state->getTransformedLineWidth()); m_painter->setPen(m_currentPen); }
CWE-189
873
11,487
270960676403969554140475749785438051382
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateMiterLimit(GfxState *state) { }
CWE-189
874
11,488
251411096219673574758465827462635817044
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void ArthurOutputDev::updateStrokeColor(GfxState *state) { GfxRGB rgb; QColor penColour = m_currentPen.color(); state->getStrokeRGB(&rgb); penColour.setRgbF(colToDbl(rgb.r), colToDbl(rgb.g), colToDbl(rgb.b), penColour.alphaF()); m_currentPen.setColor(penColour); m_painter->setPen(m_currentPen); }
CWE-189
875
11,489
334848075456560773796150638100805248833
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
~SplashOutFontFileID() {}
CWE-189
877
11,490
30174326049430701818568474685396018690
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
CairoImage::CairoImage (double x1, double y1, double x2, double y2) { this->image = NULL; this->x1 = x1; this->y1 = y1; this->x2 = x2; this->y2 = y2; }
CWE-189
878
11,491
106702228487833537079983715914690160344
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
CairoImageOutputDev::CairoImageOutputDev() { images = NULL; numImages = 0; size = 0; imgDrawCbk = NULL; imgDrawCbkData = NULL; }
CWE-189
879
11,492
38320210009037121123653752241308126353
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, GfxColorSpace * blendingColorSpace, GBool /*isolated*/, GBool knockout, GBool forSoftMask) { /* push color space */ ColorSpaceStack* css = new ColorSpaceStack; css->cs = blendingColorSpace; css->knockout = knockout; css->next = groupColorSpaceStack; groupColorSpaceStack = css; if (knockout) { knockoutCount++; if (!cairo_shape) { /* create a surface for tracking the shape */ cairo_surface_t *cairo_shape_surface = cairo_surface_create_similar_clip (cairo, CAIRO_CONTENT_ALPHA); cairo_shape = cairo_create (cairo_shape_surface); cairo_surface_destroy (cairo_shape_surface); /* the color doesn't matter as long as it is opaque */ cairo_set_source_rgb (cairo_shape, 0, 0, 0); cairo_matrix_t matrix; cairo_get_matrix (cairo, &matrix); cairo_set_matrix (cairo_shape, &matrix); } else { cairo_reference (cairo_shape); } } if (groupColorSpaceStack->next && groupColorSpaceStack->next->knockout) { /* we need to track the shape */ cairo_push_group (cairo_shape); } if (0 && forSoftMask) cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA); else cairo_push_group (cairo); /* push_group has an implicit cairo_save() */ if (knockout) { /*XXX: let's hope this matches the semantics needed */ cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); } else { cairo_set_operator(cairo, CAIRO_OPERATOR_OVER); } }
CWE-189
882
11,493
292548150146019621638266532383988599926
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen) { cairo_save (cairo); double *ctm; cairo_matrix_t matrix; ctm = state->getCTM(); matrix.xx = ctm[0]; matrix.yx = ctm[1]; matrix.xy = ctm[2]; matrix.yy = ctm[3]; matrix.x0 = ctm[4]; matrix.y0 = ctm[5]; /* Restore the original matrix and then transform to matrix needed for the * type3 font. This is ugly but seems to work. Perhaps there is a better way to do it?*/ cairo_set_matrix(cairo, &orig_matrix); cairo_transform(cairo, &matrix); if (cairo_shape) { cairo_save (cairo_shape); cairo_set_matrix(cairo_shape, &orig_matrix); cairo_transform(cairo_shape, &matrix); } cairo_pattern_destroy(stroke_pattern); cairo_pattern_reference(fill_pattern); stroke_pattern = fill_pattern; return gFalse; }
CWE-189
883
11,494
174678674575563942166073837991364243815
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content) { double x1, y1, x2, y2; int width, height; cairo_clip_extents (cairo, &x1, &y1, &x2, &y2); cairo_matrix_t matrix; cairo_get_matrix (cairo, &matrix); cairo_user_to_device(cairo, &x1, &y1); cairo_user_to_device(cairo, &x2, &y2); width = splashCeil(x2) - splashFloor(x1); height = splashFloor(y1) - splashCeil(y2); cairo_surface_t *target = cairo_get_target (cairo); cairo_surface_t *result; result = cairo_surface_create_similar (target, content, width, height); double x_offset, y_offset; cairo_surface_get_device_offset(target, &x_offset, &y_offset); cairo_surface_set_device_offset(result, x_offset, y_offset); return result; }
CWE-189
884
11,495
305032121556608332316605494446443373146
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::clearSoftMask(GfxState * /*state*/) { if (mask) cairo_pattern_destroy(mask); mask = NULL; }
CWE-189
885
11,496
320623634586501625714309021001485094410
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::clip(GfxState *state) { doPath (cairo, state, state->getPath()); cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING); cairo_clip (cairo); LOG (printf ("clip\n")); if (cairo_shape) { doPath (cairo_shape, state, state->getPath()); cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_WINDING); cairo_clip (cairo_shape); } }
CWE-189
886
11,497
262427771906686961813203815400889333798
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode *u, int uLen) { if (currentFont) { glyphs[glyphCount].index = currentFont->getGlyph (code, u, uLen); glyphs[glyphCount].x = x - originX; glyphs[glyphCount].y = y - originY; glyphCount++; } if (!text) return; actualText->addChar (state, x, y, dx, dy, code, nBytes, u, uLen); }
CWE-189
888
11,498
316413221059141785760182791421427136650
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg) { cairo_t *cr; cairo_surface_t *surface; double x1, y1, x2, y2; double *ctm; double mat[6]; CairoImage *image; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; x1 = mat[4]; y1 = mat[5]; x2 = x1 + width; y2 = y1 + height; image = new CairoImage (x1, y1, x2, y2); saveImage (image); if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cr = cairo_create (surface); setCairo (cr); cairo_translate (cr, 0, height); cairo_scale (cr, width, -height); CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg); image->setImage (surface); setCairo (NULL); cairo_surface_destroy (surface); cairo_destroy (cr); } }
CWE-189
889
11,499
328888307888557298974205599212770002483
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { /* FIXME: Doesn't the image mask support any colorspace? */ cairo_set_source (cairo, fill_pattern); /* work around a cairo bug when scaling 1x1 surfaces */ if (width == 1 && height == 1) { cairo_save (cairo); cairo_rectangle (cairo, 0., 0., width, height); cairo_fill (cairo); cairo_restore (cairo); if (cairo_shape) { cairo_save (cairo_shape); cairo_rectangle (cairo_shape, 0., 0., width, height); cairo_fill (cairo_shape); cairo_restore (cairo_shape); } return; } /* shape is 1.0 for painted areas, 0.0 for unpainted ones */ cairo_matrix_t matrix; cairo_get_matrix (cairo, &matrix); if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) { drawImageMaskPrescaled(state, ref, str, width, height, invert, inlineImg); } else { drawImageMaskRegular(state, ref, str, width, height, invert, inlineImg); } }
CWE-189
890
11,500
309859981485471536370605015499336135878
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { cairo_t *cr; cairo_surface_t *surface; double x1, y1, x2, y2; double *ctm; double mat[6]; CairoImage *image; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; x1 = mat[4]; y1 = mat[5]; x2 = x1 + width; y2 = y1 + height; image = new CairoImage (x1, y1, x2, y2); saveImage (image); if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cr = cairo_create (surface); setCairo (cr); cairo_translate (cr, 0, height); cairo_scale (cr, width, -height); CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, inlineImg); image->setImage (surface); setCairo (NULL); cairo_surface_destroy (surface); cairo_destroy (cr); } }
CWE-189
891
11,501
112593896751546342699234726872095453844
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { unsigned char *buffer; cairo_surface_t *image; cairo_pattern_t *pattern; ImageStream *imgStr; Guchar *pix; cairo_matrix_t matrix; int invert_bit; int row_stride; /* cairo does a very poor job of scaling down images so we scale them ourselves */ /* this scaling code is adopted from the splash image scaling code */ cairo_get_matrix(cairo, &matrix); #if 0 printf("[%f %f], [%f %f], %f %f\n", matrix.xx, matrix.xy, matrix.yx, matrix.yy, matrix.x0, matrix.y0); #endif /* this whole computation should be factored out */ double xScale = matrix.xx; double yScale = matrix.yy; int tx, tx2, ty, ty2; /* the integer co-oridinates of the resulting image */ int scaledHeight; int scaledWidth; if (xScale >= 0) { tx = splashRound(matrix.x0 - 0.01); tx2 = splashRound(matrix.x0 + xScale + 0.01) - 1; } else { tx = splashRound(matrix.x0 + 0.01) - 1; tx2 = splashRound(matrix.x0 + xScale - 0.01); } scaledWidth = abs(tx2 - tx) + 1; if (scaledWidth == 0) { scaledWidth = 1; } if (yScale >= 0) { ty = splashFloor(matrix.y0 + 0.01); ty2 = splashCeil(matrix.y0 + yScale - 0.01); } else { ty = splashCeil(matrix.y0 - 0.01); ty2 = splashFloor(matrix.y0 + yScale + 0.01); } scaledHeight = abs(ty2 - ty); if (scaledHeight == 0) { scaledHeight = 1; } #if 0 printf("xscale: %g, yscale: %g\n", xScale, yScale); printf("width: %d, height: %d\n", width, height); printf("scaledWidth: %d, scaledHeight: %d\n", scaledWidth, scaledHeight); #endif /* compute the required padding */ /* Padding is used to preserve the aspect ratio. We compute total_pad to make (height+total_pad)/scaledHeight as close to height/yScale as possible */ int head_pad = 0; int tail_pad = 0; int total_pad = splashRound(height*(scaledHeight/fabs(yScale)) - height); /* compute the two pieces of padding */ if (total_pad > 0) { float tail_error = fabs(matrix.y0 - ty); float head_error = fabs(ty2 - (matrix.y0 + yScale)); float tail_fraction = tail_error/(tail_error + head_error); tail_pad = splashRound(total_pad*tail_fraction); head_pad = total_pad - tail_pad; } else { tail_pad = 0; head_pad = 0; } int origHeight = height; height += tail_pad; height += head_pad; #if 0 printf("head_pad: %d tail_pad: %d\n", head_pad, tail_pad); printf("origHeight: %d height: %d\n", origHeight, height); printf("ty: %d, ty2: %d\n", ty, ty2); #endif /* TODO: Do we want to cache these? */ imgStr = new ImageStream(str, width, 1, 1); imgStr->reset(); invert_bit = invert ? 1 : 0; row_stride = (scaledWidth + 3) & ~3; buffer = (unsigned char *) malloc (scaledHeight * row_stride); if (buffer == NULL) { error(-1, "Unable to allocate memory for image."); return; } int yp = height / scaledHeight; int yq = height % scaledHeight; int xp = width / scaledWidth; int xq = width % scaledWidth; int yt = 0; int origHeight_c = origHeight; /* use MIN() because yp might be > origHeight because of padding */ unsigned char *pixBuf = (unsigned char *)malloc(MIN(yp+1, origHeight)*width); int lastYStep = 1; int total = 0; for (int y = 0; y < scaledHeight; y++) { int yStep = yp; yt += yq; if (yt >= scaledHeight) { yt -= scaledHeight; ++yStep; } { int n = (yp > 0) ? yStep : lastYStep; total += n; if (n > 0) { unsigned char *p = pixBuf; int head_pad_count = head_pad; int origHeight_count = origHeight; int tail_pad_count = tail_pad; for (int i=0; i<n; i++) { if (head_pad_count) { head_pad_count--; } else if (origHeight_count) { pix = imgStr->getLine(); for (int j=0; j<width; j++) { if (pix[j] ^ invert_bit) p[j] = 0; else p[j] = 255; } origHeight_count--; p += width; } else if (tail_pad_count) { tail_pad_count--; } else { printf("%d %d\n", n, total); assert(0 && "over run\n"); } } } } lastYStep = yStep; int k1 = y; int xt = 0; int xSrc = 0; int x1 = k1; int n = yStep > 0 ? yStep : 1; int origN = n; /* compute the size of padding and pixels that will be used for this row */ int head_pad_size = MIN(n, head_pad); n -= head_pad_size; head_pad -= MIN(head_pad_size, yStep); int pix_size = MIN(n, origHeight); n -= pix_size; origHeight -= MIN(pix_size, yStep); int tail_pad_size = MIN(n, tail_pad); n -= tail_pad_size; tail_pad -= MIN(tail_pad_size, yStep); if (n != 0) { printf("n = %d (%d %d %d)\n", n, head_pad_size, pix_size, tail_pad_size); assert(n == 0); } for (int x = 0; x < scaledWidth; ++x) { int xStep = xp; xt += xq; if (xt >= scaledWidth) { xt -= scaledWidth; ++xStep; } int m = xStep > 0 ? xStep : 1; float pixAcc0 = 0; /* could m * head_pad_size * tail_pad_size overflow? */ if (invert_bit) { pixAcc0 += m * head_pad_size * tail_pad_size * 255; } else { pixAcc0 += m * head_pad_size * tail_pad_size * 0; } /* Accumulate all of the source pixels for the destination pixel */ for (int i = 0; i < pix_size; ++i) { for (int j = 0; j< m; ++j) { if (xSrc + i*width + j > MIN(yp + 1, origHeight_c)*width) { printf("%d > %d (%d %d %d %d) (%d %d %d)\n", xSrc + i*width + j, MIN(yp + 1, origHeight_c)*width, xSrc, i , width, j, yp, origHeight_c, width); printf("%d %d %d\n", head_pad_size, pix_size, tail_pad_size); assert(0 && "bad access\n"); } pixAcc0 += pixBuf[xSrc + i*width + j]; } } buffer[y * row_stride + x] = splashFloor(pixAcc0 / (origN*m)); xSrc += xStep; x1 += 1; } } free(pixBuf); image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8, scaledWidth, scaledHeight, row_stride); if (image == NULL) { delete imgStr; return; } pattern = cairo_pattern_create_for_surface (image); if (pattern == NULL) { delete imgStr; return; } /* we should actually be using CAIRO_FILTER_NEAREST here. However, * cairo doesn't yet do minifaction filtering causing scaled down * images with CAIRO_FILTER_NEAREST to look really bad */ cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST); cairo_save (cairo); /* modify our current transformation so that the prescaled image * goes where it is supposed to */ cairo_get_matrix(cairo, &matrix); cairo_scale(cairo, 1.0/matrix.xx, 1.0/matrix.yy); cairo_translate (cairo, tx - matrix.x0, ty2 - matrix.y0); if (yScale > 0) cairo_scale(cairo, 1, -1); cairo_mask (cairo, pattern); cairo_restore(cairo); if (cairo_shape) { cairo_save (cairo_shape); /* modify our current transformation so that the prescaled image * goes where it is supposed to */ cairo_get_matrix(cairo_shape, &matrix); cairo_scale(cairo_shape, 1.0/matrix.xx, 1.0/matrix.yy); cairo_translate (cairo_shape, tx - matrix.x0, ty2 - matrix.y0); if (yScale > 0) cairo_scale(cairo_shape, 1, -1); cairo_mask (cairo_shape, pattern); cairo_restore(cairo_shape); } cairo_pattern_destroy (pattern); cairo_surface_destroy (image); free (buffer); delete imgStr; }
CWE-189
892
11,502
128210515128684001860344196183164105061
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { unsigned char *buffer; unsigned char *dest; cairo_surface_t *image; cairo_pattern_t *pattern; int x, y; ImageStream *imgStr; Guchar *pix; cairo_matrix_t matrix; int invert_bit; int row_stride; row_stride = (width + 3) & ~3; buffer = (unsigned char *) malloc (height * row_stride); if (buffer == NULL) { error(-1, "Unable to allocate memory for image."); return; } /* TODO: Do we want to cache these? */ imgStr = new ImageStream(str, width, 1, 1); imgStr->reset(); invert_bit = invert ? 1 : 0; for (y = 0; y < height; y++) { pix = imgStr->getLine(); dest = buffer + y * row_stride; for (x = 0; x < width; x++) { if (pix[x] ^ invert_bit) *dest++ = 0; else *dest++ = 255; } } image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8, width, height, row_stride); if (image == NULL) { delete imgStr; return; } pattern = cairo_pattern_create_for_surface (image); if (pattern == NULL) { delete imgStr; return; } cairo_matrix_init_translate (&matrix, 0, height); cairo_matrix_scale (&matrix, width, -height); cairo_pattern_set_matrix (pattern, &matrix); /* we should actually be using CAIRO_FILTER_NEAREST here. However, * cairo doesn't yet do minifaction filtering causing scaled down * images with CAIRO_FILTER_NEAREST to look really bad */ cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST); cairo_mask (cairo, pattern); if (cairo_shape) { #if 0 cairo_rectangle (cairo_shape, 0., 0., width, height); cairo_fill (cairo_shape); #else cairo_save (cairo_shape); /* this should draw a rectangle the size of the image * we use this instead of rect,fill because of the lack * of EXTEND_PAD */ /* NOTE: this will multiply the edges of the image twice */ cairo_set_source (cairo_shape, pattern); cairo_mask (cairo_shape, pattern); cairo_restore (cairo_shape); #endif } cairo_pattern_destroy (pattern); cairo_surface_destroy (image); free (buffer); delete imgStr; }
CWE-189
893
11,503
153273078064096384994080994920457529112
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert) { cairo_t *cr; cairo_surface_t *surface; double x1, y1, x2, y2; double *ctm; double mat[6]; CairoImage *image; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; x1 = mat[4]; y1 = mat[5]; x2 = x1 + width; y2 = y1 + height; image = new CairoImage (x1, y1, x2, y2); saveImage (image); if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cr = cairo_create (surface); setCairo (cr); cairo_translate (cr, 0, height); cairo_scale (cr, width, -height); CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert); image->setImage (surface); setCairo (NULL); cairo_surface_destroy (surface); cairo_destroy (cr); } }
CWE-189
895
11,504
186029399246542455981625446969378387961
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap) { cairo_t *cr; cairo_surface_t *surface; double x1, y1, x2, y2; double *ctm; double mat[6]; CairoImage *image; ctm = state->getCTM(); mat[0] = ctm[0]; mat[1] = ctm[1]; mat[2] = -ctm[2]; mat[3] = -ctm[3]; mat[4] = ctm[2] + ctm[4]; mat[5] = ctm[3] + ctm[5]; x1 = mat[4]; y1 = mat[5]; x2 = x1 + width; y2 = y1 + height; image = new CairoImage (x1, y1, x2, y2); saveImage (image); if (imgDrawCbk && imgDrawCbk (numImages - 1, imgDrawCbkData)) { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cr = cairo_create (surface); setCairo (cr); cairo_translate (cr, 0, height); cairo_scale (cr, width, -height); CairoOutputDev::drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); image->setImage (surface); setCairo (NULL); cairo_surface_destroy (surface); cairo_destroy (cr); } }
CWE-189
896
11,505
27333081761930173825638959217945370196
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::endMarkedContent(GfxState *state) { if (text) actualText->endMC(state); }
CWE-189
897
11,506
282206456321519977858268677579255156412
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::endPage() { if (text) { text->endPage(); text->coalesce(gTrue, gFalse); } }
CWE-189
898
11,507
136593610970009850982360637357665049583
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::endTextObject(GfxState *state) { if (textClipPath) { cairo_append_path (cairo, textClipPath); cairo_clip (cairo); if (cairo_shape) { cairo_append_path (cairo_shape, textClipPath); cairo_clip (cairo_shape); } cairo_path_destroy (textClipPath); textClipPath = NULL; } }
CWE-189
900
11,508
265701267921820773557543721245128010035
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::endTransparencyGroup(GfxState * /*state*/) { if (group) cairo_pattern_destroy(group); group = cairo_pop_group (cairo); if (groupColorSpaceStack->next && groupColorSpaceStack->next->knockout) { if (shape) cairo_pattern_destroy(shape); shape = cairo_pop_group (cairo_shape); } }
CWE-189
901
11,509
34095238979427235781041407371148945464
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::endType3Char(GfxState *state) { cairo_restore (cairo); if (cairo_shape) { cairo_restore (cairo_shape); } }
CWE-189
902
11,510
370295061242976812268056157068736517
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::eoClip(GfxState *state) { doPath (cairo, state, state->getPath()); cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip (cairo); LOG (printf ("clip-eo\n")); if (cairo_shape) { doPath (cairo_shape, state, state->getPath()); cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip (cairo_shape); } }
CWE-189
903
11,511
191168610033059106401466535241155932554
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::eoFill(GfxState *state) { doPath (cairo, state, state->getPath()); cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_EVEN_ODD); cairo_set_source (cairo, fill_pattern); LOG(printf ("fill-eo\n")); cairo_fill (cairo); if (cairo_shape) { cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_EVEN_ODD); doPath (cairo_shape, state, state->getPath()); cairo_fill (cairo_shape); } }
CWE-189
904
11,512
329768278631721071700902864489697280177
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::fill(GfxState *state) { doPath (cairo, state, state->getPath()); cairo_set_fill_rule (cairo, CAIRO_FILL_RULE_WINDING); cairo_set_source (cairo, fill_pattern); LOG(printf ("fill\n")); cairo_fill (cairo); if (cairo_shape) { cairo_set_fill_rule (cairo_shape, CAIRO_FILL_RULE_WINDING); doPath (cairo_shape, state, state->getPath()); cairo_fill (cairo_shape); } }
CWE-189
905
11,513
257442728908851453704358352762452846946
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static uint32_t luminocity(uint32_t x) { int r = (x >> 16) & 0xff; int g = (x >> 8) & 0xff; int b = (x >> 0) & 0xff; int y = (r*19661+g*38666+b*7209 + 32829)>>16; return y << 24; }
CWE-189
906
11,514
203911831357801295783680264815793641887
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) { cairo_set_source (cairo, group); if (!mask) { if (shape) { cairo_save (cairo); /* OPERATOR_SOURCE w/ a mask is defined as (src IN mask) ADD (dest OUT mask) * however our source has already been clipped to mask so we only need to * do ADD and OUT */ /* clear the shape mask */ cairo_set_source (cairo, shape); cairo_set_operator (cairo, CAIRO_OPERATOR_DEST_OUT); cairo_paint (cairo); cairo_set_operator (cairo, CAIRO_OPERATOR_ADD); cairo_set_source (cairo, group); cairo_paint (cairo); cairo_restore (cairo); cairo_pattern_destroy (shape); shape = NULL; } else { cairo_paint_with_alpha (cairo, fill_opacity); } cairo_status_t status = cairo_status(cairo); if (status) printf("BAD status: %s\n", cairo_status_to_string(status)); } else { cairo_mask(cairo, mask); cairo_pattern_destroy(mask); mask = NULL; } popTransparencyGroup(); }
CWE-189
907
11,515
129571421483608596367910214283508558588
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static inline void printMatrix(cairo_matrix_t *matrix){ printf("%f %f, %f %f (%f %f)\n", matrix->xx, matrix->yx, matrix->xy, matrix->yy, matrix->x0, matrix->y0); }
CWE-189
909
11,516
199968111152656386363313235312882573593
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::restoreState(GfxState *state) { LOG(printf ("restore\n")); cairo_restore (cairo); if (cairo_shape) cairo_restore (cairo_shape); /* These aren't restored by cairo_restore() since we keep them in * the output device. */ updateFillColor(state); updateStrokeColor(state); updateFillOpacity(state); updateStrokeOpacity(state); MaskStack* ms = maskStack; if (mask) cairo_pattern_destroy(mask); mask = ms->mask; maskStack = ms->next; delete ms; }
CWE-189
910
11,517
243739837132130924555044333244443463111
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoImageOutputDev::saveImage(CairoImage *image) { if (numImages >= size) { size += 16; images = (CairoImage **) greallocn (images, size, sizeof (CairoImage *)); } images[numImages++] = image; }
CWE-189
911
11,518
147318395780139387490240899543804560106
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::saveState(GfxState *state) { LOG(printf ("save\n")); cairo_save (cairo); if (cairo_shape) cairo_save (cairo_shape); MaskStack *ms = new MaskStack; ms->mask = cairo_pattern_reference(mask); ms->next = maskStack; maskStack = ms; }
CWE-189
912
11,519
154023716264802514010148117651320966599
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::setCairo(cairo_t *cairo) { if (this->cairo != NULL) { cairo_status_t status = cairo_status (this->cairo); if (status) { warning("cairo context error: %s\n", cairo_status_to_string(status)); } cairo_destroy (this->cairo); assert(!cairo_shape); } if (cairo != NULL) { this->cairo = cairo_reference (cairo); /* save the initial matrix so that we can use it for type3 fonts. */ cairo_get_matrix(cairo, &orig_matrix); } else { this->cairo = NULL; this->cairo_shape = NULL; } }
CWE-189
913
11,520
4989772599989413106602125738898217857
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::setDefaultCTM(double *ctm) { cairo_matrix_t matrix; matrix.xx = ctm[0]; matrix.yx = ctm[1]; matrix.xy = ctm[2]; matrix.yy = ctm[3]; matrix.x0 = ctm[4]; matrix.y0 = ctm[5]; cairo_transform (cairo, &matrix); if (cairo_shape) cairo_transform (cairo_shape, &matrix); OutputDev::setDefaultCTM(ctm); }
CWE-189
914
11,521
6624961560150571830735865907090343649
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, Function * transferFunc, GfxColor * backdropColor) { cairo_pattern_destroy(mask); if (alpha == false) { /* We need to mask according to the luminocity of the group. * So we paint the group to an image surface convert it to a luminocity map * and then use that as the mask. */ double x1, y1, x2, y2, tmp; cairo_clip_extents(cairo, &x1, &y1, &x2, &y2); cairo_user_to_device(cairo, &x1, &y1); cairo_user_to_device(cairo, &x2, &y2); if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; } int width = (int)(ceil(x2) - floor(x1)); int height = (int)(ceil(y2) - floor(y1)); cairo_surface_t *source = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_t *maskCtx = cairo_create(source); GfxRGB backdropColorRGB; groupColorSpaceStack->cs->getRGB(backdropColor, &backdropColorRGB); /* paint the backdrop */ cairo_set_source_rgb(maskCtx, backdropColorRGB.r / 65535.0, backdropColorRGB.g / 65535.0, backdropColorRGB.b / 65535.0); cairo_matrix_t mat; cairo_get_matrix(cairo, &mat); cairo_set_matrix(maskCtx, &mat); /* make the device offset of the new mask match that of the group */ double x_offset, y_offset; cairo_surface_t *pats; cairo_pattern_get_surface(group, &pats); cairo_surface_get_device_offset(pats, &x_offset, &y_offset); cairo_surface_set_device_offset(source, x_offset, y_offset); /* paint the group */ cairo_set_source(maskCtx, group); cairo_paint(maskCtx); /* XXX status = cairo_status(maskCtx); */ cairo_destroy(maskCtx); /* convert to a luminocity map */ uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source); /* get stride in units of 32 bits */ int stride = cairo_image_surface_get_stride(source)/4; for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { source_data[y*stride + x] = luminocity(source_data[y*stride + x]); #if 0 here is how splash deals with the transferfunction we should deal with this at some point if (transferFunc) { transferFunc->transform(&lum, &lum2); } else { lum2 = lum; } p[x] = (int)(lum2 * 255.0 + 0.5); #endif } } /* setup the new mask pattern */ mask = cairo_pattern_create_for_surface(source); cairo_matrix_t patMatrix; cairo_pattern_get_matrix(group, &patMatrix); cairo_pattern_set_matrix(mask, &patMatrix); cairo_surface_destroy(source); } else { mask = cairo_pattern_reference(group); } popTransparencyGroup(); }
CWE-189
916
11,522
310100646169460690392744294129355205006
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::setTextPage(TextPage *text) { if (this->text) this->text->decRefCnt(); if (actualText) delete actualText; if (text) { this->text = text; this->text->incRefCnt(); actualText = new ActualText(text); } else { this->text = NULL; actualText = NULL; } }
CWE-189
917
11,523
12486037074109764010256217395848907581
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static inline int splashCeil(SplashCoord x) { return (int)ceil(x); }
CWE-189
918
11,524
35081087309469845719645698193344416678
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static inline int splashRound(SplashCoord x) { return (int)floor(x + 0.5); }
CWE-189
920
11,525
168377486229153934057075844663801664864
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::startDoc(XRef *xrefA, Catalog *catalogA, CairoFontEngine *parentFontEngine) { xref = xrefA; catalog = catalogA; if (parentFontEngine) { fontEngine = parentFontEngine; } else { if (fontEngine) { delete fontEngine; } fontEngine = new CairoFontEngine(ft_lib); fontEngine_owner = gTrue; } }
CWE-189
921
11,526
59626809908558610319642760492718563164
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::startPage(int pageNum, GfxState *state) { /* set up some per page defaults */ cairo_pattern_destroy(fill_pattern); fill_pattern = cairo_pattern_create_rgb(0., 0., 0.); cairo_pattern_destroy(stroke_pattern); stroke_pattern = cairo_pattern_create_rgb(0., 0., 0.); if (text) text->startPage(state); }
CWE-189
922
11,527
147093106679508223221434370466873527019
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::stroke(GfxState *state) { doPath (cairo, state, state->getPath()); cairo_set_source (cairo, stroke_pattern); LOG(printf ("stroke\n")); cairo_stroke (cairo); if (cairo_shape) { doPath (cairo_shape, state, state->getPath()); cairo_stroke (cairo_shape); } }
CWE-189
923
11,528
321610192600883248111518712837953133565
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::type3D0(GfxState *state, double wx, double wy) { t3_glyph_wx = wx; t3_glyph_wy = wy; }
CWE-189
924
11,529
106265293223539622006780827831279251994
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { t3_glyph_wx = wx; t3_glyph_wy = wy; t3_glyph_bbox[0] = llx; t3_glyph_bbox[1] = lly; t3_glyph_bbox[2] = urx; t3_glyph_bbox[3] = ury; t3_glyph_has_bbox = gTrue; }
CWE-189
925
11,530
170928025134555453217535742824354471791
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateFillColor(GfxState *state) { state->getFillRGB(&fill_color); cairo_pattern_destroy(fill_pattern); fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0, fill_color.g / 65535.0, fill_color.b / 65535.0, fill_opacity); LOG(printf ("fill color: %d %d %d\n", fill_color.r, fill_color.g, fill_color.b)); }
CWE-189
928
11,531
293824129643766586118710729506237760028
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateFillOpacity(GfxState *state) { fill_opacity = state->getFillOpacity(); cairo_pattern_destroy(fill_pattern); fill_pattern = cairo_pattern_create_rgba(fill_color.r / 65535.0, fill_color.g / 65535.0, fill_color.b / 65535.0, fill_opacity); LOG(printf ("fill opacity: %f\n", fill_opacity)); }
CWE-189
929
11,532
221331036936106725214558833197811958427
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateFlatness(GfxState *state) { }
CWE-189
930
11,533
171539720257078036786426529996502629791
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateFont(GfxState *state) { cairo_font_face_t *font_face; cairo_matrix_t matrix, invert_matrix; LOG(printf ("updateFont() font=%s\n", state->getFont()->getName()->getCString())); needFontUpdate = gFalse; if (text) text->updateFont(state); currentFont = fontEngine->getFont (state->getFont(), xref, catalog, printing); if (!currentFont) return; LOG(printf ("font matrix: %f %f %f %f\n", m11, m12, m21, m22)); font_face = currentFont->getFontFace(); cairo_set_font_face (cairo, font_face); double fontSize = state->getFontSize(); double *m = state->getTextMat(); /* NOTE: adjusting by a constant is hack. The correct solution * is probably to use user-fonts and compute the scale on a per * glyph basis instead of for the entire font */ double w = currentFont->getSubstitutionCorrection(state->getFont()); matrix.xx = m[0] * fontSize * state->getHorizScaling() * w; matrix.yx = m[1] * fontSize * state->getHorizScaling() * w; matrix.xy = -m[2] * fontSize; matrix.yy = -m[3] * fontSize; matrix.x0 = 0; matrix.y0 = 0; /* Make sure the font matrix is invertible before setting it. cairo * will blow up if we give it a matrix that's not invertible, so we * need to check before passing it to cairo_set_font_matrix. Ignoring it * is likely to give better results than not rendering anything at * all. See #18254. */ invert_matrix = matrix; if (cairo_matrix_invert(&invert_matrix)) { warning("font matrix not invertible\n"); return; } cairo_set_font_matrix (cairo, &matrix); }
CWE-189
931
11,534
230500914587328593925472331333281581323
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateLineCap(GfxState *state) { switch (state->getLineCap()) { case 0: cairo_set_line_cap (cairo, CAIRO_LINE_CAP_BUTT); break; case 1: cairo_set_line_cap (cairo, CAIRO_LINE_CAP_ROUND); break; case 2: cairo_set_line_cap (cairo, CAIRO_LINE_CAP_SQUARE); break; } if (cairo_shape) cairo_set_line_cap (cairo_shape, cairo_get_line_cap(cairo)); }
CWE-189
932
11,535
192935915105204185045303234300768622652
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateLineDash(GfxState *state) { double *dashPattern; int dashLength; double dashStart; state->getLineDash(&dashPattern, &dashLength, &dashStart); cairo_set_dash (cairo, dashPattern, dashLength, dashStart); if (cairo_shape) cairo_set_dash (cairo_shape, dashPattern, dashLength, dashStart); }
CWE-189
933
11,536
24184048655068236768100003042110955193
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateLineJoin(GfxState *state) { switch (state->getLineJoin()) { case 0: cairo_set_line_join (cairo, CAIRO_LINE_JOIN_MITER); break; case 1: cairo_set_line_join (cairo, CAIRO_LINE_JOIN_ROUND); break; case 2: cairo_set_line_join (cairo, CAIRO_LINE_JOIN_BEVEL); break; } if (cairo_shape) cairo_set_line_join (cairo_shape, cairo_get_line_join(cairo)); }
CWE-189
934
11,537
84577187593341428633907843220144845332
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateLineWidth(GfxState *state) { LOG(printf ("line width: %f\n", state->getLineWidth())); if (state->getLineWidth() == 0.0) { /* find out how big pixels (device unit) are in the x and y directions * choose the smaller of the two as our line width */ double x = 1.0, y = 1.0; cairo_device_to_user_distance(cairo, &x, &y); cairo_set_line_width (cairo, MIN(fabs(x),fabs(y))); } else { cairo_set_line_width (cairo, state->getLineWidth()); } if (cairo_shape) cairo_set_line_width (cairo_shape, cairo_get_line_width (cairo)); }
CWE-189
935
11,538
206701378369454499421630588829529708479
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateMiterLimit(GfxState *state) { cairo_set_miter_limit (cairo, state->getMiterLimit()); if (cairo_shape) cairo_set_miter_limit (cairo_shape, state->getMiterLimit()); }
CWE-189
936
11,539
121148213690846549767301850992778973067
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateStrokeColor(GfxState *state) { state->getStrokeRGB(&stroke_color); cairo_pattern_destroy(stroke_pattern); stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0, stroke_color.g / 65535.0, stroke_color.b / 65535.0, stroke_opacity); LOG(printf ("stroke color: %d %d %d\n", stroke_color.r, stroke_color.g, stroke_color.b)); }
CWE-189
937
11,540
133545711846882828519966302313359534920
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
void CairoOutputDev::updateStrokeOpacity(GfxState *state) { stroke_opacity = state->getStrokeOpacity(); cairo_pattern_destroy(stroke_pattern); stroke_pattern = cairo_pattern_create_rgba(stroke_color.r / 65535.0, stroke_color.g / 65535.0, stroke_color.b / 65535.0, stroke_opacity); LOG(printf ("stroke opacity: %f\n", stroke_opacity)); }
CWE-189
938
11,541
199352578447035345482196198760488670394
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
CairoImage::~CairoImage () { if (image) cairo_surface_destroy (image); }
CWE-189
939
11,542
262454262158857888550329366661894708987
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
CairoImageOutputDev::~CairoImageOutputDev() { int i; for (i = 0; i < numImages; i++) delete images[i]; gfree (images); }
CWE-189
940
11,543
266445528623246670717983568731192040540
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
CairoOutputDev::~CairoOutputDev() { if (fontEngine_owner && fontEngine) { delete fontEngine; } if (cairo) cairo_destroy (cairo); cairo_pattern_destroy (stroke_pattern); cairo_pattern_destroy (fill_pattern); if (group) cairo_pattern_destroy (group); if (mask) cairo_pattern_destroy (mask); if (shape) cairo_pattern_destroy (shape); if (text) text->decRefCnt(); if (actualText) delete actualText; }
CWE-189
941
11,544
122512689511711832253066564147506123160
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
static int CMSError(int ecode, const char *msg) { error(-1,const_cast<char *>(msg)); return 1; }
CWE-189
942
11,545
231510074591313800021408389787761844319
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GfxAxialShading::GfxAxialShading(double x0A, double y0A, double x1A, double y1A, double t0A, double t1A, Function **funcsA, int nFuncsA, GBool extend0A, GBool extend1A): GfxShading(2) { int i; x0 = x0A; y0 = y0A; x1 = x1A; y1 = y1A; t0 = t0A; t1 = t1A; nFuncs = nFuncsA; for (i = 0; i < nFuncs; ++i) { funcs[i] = funcsA[i]; } extend0 = extend0A; extend1 = extend1A; }
CWE-189
943
11,546
280230497928447503749660207749707622857
null
null
null
poppler
7b2d314a61fd0e12f47c62996cb49ec0d1ba747a
0
GfxAxialShading::GfxAxialShading(GfxAxialShading *shading): GfxShading(shading) { int i; x0 = shading->x0; y0 = shading->y0; x1 = shading->x1; y1 = shading->y1; t0 = shading->t0; t1 = shading->t1; nFuncs = shading->nFuncs; for (i = 0; i < nFuncs; ++i) { funcs[i] = shading->funcs[i]->copy(); } extend0 = shading->extend0; extend1 = shading->extend1; }
CWE-189
944
11,547
277192915801353655739451748006955836139
null
null
null