diff options
author | raveit65 <[email protected]> | 2016-07-03 13:35:50 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-07-03 13:35:50 +0200 |
commit | 5ce4313534dd258ddc2ec494e71cbe927a41d1c7 (patch) | |
tree | 8b0f6b69e4bcd3365be565b23ca19dce66029310 /backend/tiff | |
parent | 85ee1df4499969dd3c6dee3bd032a18d8bc34999 (diff) | |
download | atril-5ce4313534dd258ddc2ec494e71cbe927a41d1c7.tar.bz2 atril-5ce4313534dd258ddc2ec494e71cbe927a41d1c7.tar.xz |
tiff: issue warnings on print errors
taken from:
https://git.gnome.org/browse/evince/commit/?id=3f85a30
Diffstat (limited to 'backend/tiff')
-rw-r--r-- | backend/tiff/tiff-document.c | 23 |
1 files changed, 17 insertions, 6 deletions
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, |