summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2017-05-05 00:57:35 +0200
committerAlbert Astals Cid <aacid@kde.org>2017-05-05 00:57:35 +0200
commit9ad9d92591a6389f84919ff2de3668c2b6158dc9 (patch)
treed92f5250bfc5c55d97f564f32f3458cdc2a440c7
parentcdab9a2dc27a10c84550db28fac8dbdcdcd4d29d (diff)
Fix memory leak in error condition
Coverity was complaining we missed one delete in one of the error conditions, so just made colorMap not be newer, no need to care about deletes ;)
-rw-r--r--poppler/Gfx.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a2d1db0c..37220280 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4264,7 +4264,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
GBool mask;
GBool invert;
GfxColorSpace *colorSpace, *maskColorSpace;
- GfxImageColorMap *colorMap, *maskColorMap;
+ GfxImageColorMap *maskColorMap;
Object maskObj, smaskObj;
GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
int maskColors[2*gfxColorMaxComps];
@@ -4482,10 +4482,9 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
obj1.free();
dict->lookup("D", &obj1);
}
- colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
+ GfxImageColorMap colorMap(bits, &obj1, colorSpace);
obj1.free();
- if (!colorMap->isOk()) {
- delete colorMap;
+ if (!colorMap.isOk()) {
goto err1;
}
@@ -4692,8 +4691,8 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
// if drawing is disabled, skip over inline image data
if (!ocState || !out->needNonText()) {
str->reset();
- n = height * ((width * colorMap->getNumPixelComps() *
- colorMap->getBits() + 7) / 8);
+ n = height * ((width * colorMap.getNumPixelComps() *
+ colorMap.getBits() + 7) / 8);
for (i = 0; i < n; ++i) {
str->getChar();
}
@@ -4702,18 +4701,17 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
// draw it
} else {
if (haveSoftMask) {
- out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate,
+ out->drawSoftMaskedImage(state, ref, str, width, height, &colorMap, interpolate,
maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate);
delete maskColorMap;
} else if (haveExplicitMask) {
- out->drawMaskedImage(state, ref, str, width, height, colorMap, interpolate,
+ out->drawMaskedImage(state, ref, str, width, height, &colorMap, interpolate,
maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate);
} else {
- out->drawImage(state, ref, str, width, height, colorMap, interpolate,
+ out->drawImage(state, ref, str, width, height, &colorMap, interpolate,
haveColorKeyMask ? maskColors : (int *)NULL, inlineImg);
}
}
- delete colorMap;
maskObj.free();
smaskObj.free();