utils/ImageOutputDev.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
New commits: commit 104fc940ca3c3eb8b706abd11d35be83dbcd0c3b Author: Albert Astals Cid <aa...@kde.org> Date: Mon Mar 29 19:12:23 2021 +0200 pdfimages: Do not assert in "too big images" Fixes #1061 diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc index 879d94ee..4bb9d8ab 100644 --- a/utils/ImageOutputDev.cc +++ b/utils/ImageOutputDev.cc @@ -373,6 +373,16 @@ void ImageOutputDev::writeImageFile(ImgWriter *writer, ImageFormat format, const } } + int pixelSize = sizeof(unsigned int); + if (format == imgRGB48) + pixelSize = 2 * sizeof(unsigned int); + + row = (unsigned char *)gmallocn_checkoverflow(width, pixelSize); + if (!row) { + error(errIO, -1, "Image data for '{0:s}' is too big. {1:d} width with {2:d} bytes per pixel", fileName, width, pixelSize); + return; + } + if (format != imgMonochrome) { // initialize stream imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits()); @@ -382,12 +392,6 @@ void ImageOutputDev::writeImageFile(ImgWriter *writer, ImageFormat format, const str->reset(); } - int pixelSize = sizeof(unsigned int); - if (format == imgRGB48) - pixelSize = 2 * sizeof(unsigned int); - - row = (unsigned char *)gmallocn(width, pixelSize); - // PDF masks use 0 = draw current color, 1 = leave unchanged. // We invert this to provide the standard interpretation of alpha // (0 = transparent, 1 = opaque). If the colorMap already inverts _______________________________________________ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler