From 5ce4313534dd258ddc2ec494e71cbe927a41d1c7 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 3 Jul 2016 13:35:50 +0200 Subject: tiff: issue warnings on print errors taken from: https://git.gnome.org/browse/evince/commit/?id=3f85a30 --- backend/tiff/tiff-document.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c index 854051de..52c35d6e 100644 --- a/backend/tiff/tiff-document.c +++ b/backend/tiff/tiff-document.c @@ -231,16 +231,19 @@ tiff_document_render (EvDocument *document, push_handlers (); if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) { pop_handlers (); + g_warning("Failed to select page %d", rc->page->index); return NULL; } if (!TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &width)) { pop_handlers (); + g_warning("Failed to read image width"); return NULL; } if (! TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &height)) { pop_handlers (); + g_warning("Failed to read image height"); return NULL; } @@ -253,26 +256,34 @@ tiff_document_render (EvDocument *document, pop_handlers (); /* Sanity check the doc */ - if (width <= 0 || height <= 0) - return NULL; + if (width <= 0 || height <= 0) { + g_warning("Invalid width or height."); + return NULL; + } #ifdef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width); #else rowstride = width * 4; #endif - if (rowstride / 4 != width) + if (rowstride / 4 != width) { + g_warning("Overflow while rendering document."); /* overflow, or cairo was changed in an unsupported way */ return NULL; + } bytes = height * rowstride; - if (bytes / rowstride != height) + if (bytes / rowstride != height) { + g_warning("Overflow while rendering document."); /* overflow */ - return NULL; + return NULL; + } pixels = g_try_malloc (bytes); - if (!pixels) + if (!pixels) { + g_warning("Failed to allocate memory for rendering."); return NULL; + } surface = cairo_image_surface_create_for_data (pixels, CAIRO_FORMAT_RGB24, -- cgit v1.2.1