diff --git a/common/pdf_comic.mm b/common/pdf_comic.mm index 7f9b32ce..3eda1c07 100644 --- a/common/pdf_comic.mm +++ b/common/pdf_comic.mm @@ -97,6 +97,15 @@ QImage MacOSXPDFComic::getPage(const int pageNum) lastPageData = (void *)dataRef; + if(!lastPageData) + { + QLOG_ERROR() << "Unable to extract image from PDF file using CGPDFDocument"; + CGImageRelease(image); + CGContextRelease(bitmapContext); + CGColorSpaceRelease(genericColorSpace); + return QImage(); + } + const uchar *bytes = (const uchar *)CFDataGetBytePtr(dataRef); qtImage = QImage(bytes, pageRect.size.width, pageRect.size.height, QImage::Format_ARGB32);