[gtk/image-loading: 31/36] tiff loader: Set errors
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/image-loading: 31/36] tiff loader: Set errors
- Date: Tue, 14 Sep 2021 05:40:47 +0000 (UTC)
commit dc87037353223f065b59d40dd838879dfc59ce5f
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Sep 13 21:26:42 2021 -0400
tiff loader: Set errors
gdk/loaders/gdktiff.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gdk/loaders/gdktiff.c b/gdk/loaders/gdktiff.c
index de5d0fcca3..6f41811791 100644
--- a/gdk/loaders/gdktiff.c
+++ b/gdk/loaders/gdktiff.c
@@ -373,7 +373,7 @@ load_fallback (TIFF *tif,
if (!TIFFReadRGBAImageOriented (tif, width, height, (uint32 *)data, ORIENTATION_TOPLEFT, 1))
{
g_set_error_literal (error,
- G_IO_ERROR, G_IO_ERROR_FAILED,
+ GDK_TEXTURE_ERROR, GDK_TEXTURE_ERROR_CORRUPT_IMAGE,
"Failed to load RGB data from TIFF file");
g_free (data);
return NULL;
@@ -467,7 +467,15 @@ gdk_load_tiff (GBytes *input_bytes,
g_assert (TIFFScanlineSize (tif) == stride);
- data = g_new (guchar, height * stride);
+ data = g_try_malloc_n (height, stride);
+ if (!data)
+ {
+ g_set_error (error,
+ GDK_TEXTURE_ERROR, GDK_TEXTURE_ERROR_INSUFFICIENT_MEMORY,
+ "Not enough memory to read tiff");
+ TIFFClose (tif);
+ return NULL;
+ }
line = data;
for (int y = 0; y < height; y++)
@@ -475,7 +483,7 @@ gdk_load_tiff (GBytes *input_bytes,
if (TIFFReadScanline (tif, line, y, 0) == -1)
{
g_set_error (error,
- G_IO_ERROR, G_IO_ERROR_FAILED,
+ GDK_TEXTURE_ERROR, GDK_TEXTURE_ERROR_CORRUPT_IMAGE,
"Reading data failed at row %d", y);
TIFFClose (tif);
g_free (data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]