[evince] tiff: issue warnings on print errors
- From: Jan-Joost Spanjers <jspanjers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] tiff: issue warnings on print errors
- Date: Mon, 20 Feb 2012 12:27:31 +0000 (UTC)
commit 3f85a30d15a61ec360f81cf414da60cdbcff9102
Author: Hib Eris <hib hiberis nl>
Date: Fri Jul 15 13:48:02 2011 +0200
tiff: issue warnings on print errors
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 ca40397..7813eb8 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -240,16 +240,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;
}
@@ -262,26 +265,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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]