Commit 5051ebed authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

Make sure ImageStream::close() is called after ImageStream::reset()

parent 829ed964
......@@ -731,6 +731,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
free (buffer);
imgStr->close ();
delete imgStr;
#endif
}
......
......@@ -1134,11 +1134,13 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8,
width, height, row_stride);
if (image == NULL) {
imgStr->close();
delete imgStr;
return;
}
pattern = cairo_pattern_create_for_surface (image);
if (pattern == NULL) {
imgStr->close();
delete imgStr;
return;
}
......@@ -1175,6 +1177,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
free (buffer);
imgStr->close();
delete imgStr;
}
......@@ -1394,11 +1397,13 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8,
scaledWidth, scaledHeight, row_stride);
if (image == NULL) {
imgStr->close();
delete imgStr;
return;
}
pattern = cairo_pattern_create_for_surface (image);
if (pattern == NULL) {
imgStr->close();
delete imgStr;
return;
}
......@@ -1446,6 +1451,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
free (buffer);
imgStr->close();
delete imgStr;
}
......@@ -1485,9 +1491,8 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
maskImage = cairo_image_surface_create_for_data (maskBuffer, CAIRO_FORMAT_A8,
maskWidth, maskHeight, row_stride);
maskImgStr->close();
delete maskImgStr;
maskStr->close();
unsigned char *buffer;
unsigned int *dest;
......@@ -1521,12 +1526,14 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
width, height, width * 4);
if (image == NULL) {
imgStr->close();
delete imgStr;
return;
}
pattern = cairo_pattern_create_for_surface (image);
maskPattern = cairo_pattern_create_for_surface (maskImage);
if (pattern == NULL) {
imgStr->close();
delete imgStr;
return;
}
......@@ -1566,6 +1573,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
cairo_surface_destroy (image);
free (buffer);
free (maskBuffer);
imgStr->close();
delete imgStr;
}
......@@ -1601,8 +1609,8 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
maskImage = cairo_image_surface_create_for_data (maskBuffer, CAIRO_FORMAT_A8,
maskWidth, maskHeight, row_stride);
maskImgStr->close();
delete maskImgStr;
maskStr->close();
unsigned char *buffer;
unsigned int *dest;
......@@ -1637,12 +1645,14 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
width, height, width * 4);
if (image == NULL) {
imgStr->close();
delete imgStr;
return;
}
pattern = cairo_pattern_create_for_surface (image);
maskPattern = cairo_pattern_create_for_surface (maskImage);
if (pattern == NULL) {
imgStr->close();
delete imgStr;
return;
}
......@@ -1687,6 +1697,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
free (buffer);
free (maskBuffer);
imgStr->close();
delete imgStr;
}
void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
......@@ -1754,11 +1765,13 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
}
if (image == NULL) {
imgStr->close();
delete imgStr;
return;
}
pattern = cairo_pattern_create_for_surface (image);
if (pattern == NULL) {
imgStr->close();
delete imgStr;
return;
}
......@@ -1793,6 +1806,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
free (buffer);
imgStr->close();
delete imgStr;
}
......
......@@ -563,6 +563,7 @@ GBool Page::loadThumb(unsigned char **data_out,
}
}
*data_out = pixbufdata;
imgstr->close();
delete imgstr;
}
......
......@@ -415,6 +415,10 @@ void ImageStream::reset() {
str->reset();
}
void ImageStream::close() {
str->close();
}
GBool ImageStream::getPixel(Guchar *pix) {
int i;
......
......@@ -291,6 +291,9 @@ public:
// Reset the stream.
void reset();
// Close the stream previously reset
void close();
// Gets the next pixel from the stream. <pix> should be able to hold
// at least nComps elements. Returns false at end of file.
GBool getPixel(Guchar *pix);
......
......@@ -1414,6 +1414,7 @@ void HtmlOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
free(row);
imgList->append(fName);
++imgNum;
imgStr->close();
delete imgStr;
#else
OutputDev::drawImage(state, ref, str, width, height, colorMap,
......
......@@ -217,6 +217,7 @@ void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
p += colorMap->getNumPixelComps();
}
}
imgStr->close();
delete imgStr;
fclose(f);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment