summaryrefslogtreecommitdiff
path: root/nonprism/gthumb/0001-Do-not-process-bitmap-thumbnails-with-invalid-color-.patch
blob: e7989509ed5781750b84f80de1c1226462bf4915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 2019d1ed9d3cc6085598b92c2001690fb41af8f7 Mon Sep 17 00:00:00 2001
From: Jan de Groot <jgc@archlinux.org>
Date: Mon, 13 Feb 2017 13:28:27 +0000
Subject: [PATCH] Do not process bitmap thumbnails with invalid color settings.

Libraw sets these to 0 in an excption handler, we should not assert fatal when processing such an image.
---
 extensions/raw_files/main.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/extensions/raw_files/main.c b/extensions/raw_files/main.c
index 6cf2ff8e..726385a3 100644
--- a/extensions/raw_files/main.c
+++ b/extensions/raw_files/main.c
@@ -267,12 +267,16 @@ _cairo_image_surface_create_from_raw (GInputStream  *istream,
 							error);
 			break;
 		case LIBRAW_THUMBNAIL_BITMAP:
-			image = _libraw_read_bitmap_data (raw_data->thumbnail.twidth,
-							  raw_data->thumbnail.theight,
-							  raw_data->thumbnail.tcolors,
-							  8,
-							  (guchar *) raw_data->thumbnail.thumb,
-							  raw_data->thumbnail.tlength);
+			if (raw_data->thumbnail.tcolors > 0 && raw_data->thumbnail.tcolors < 4) {
+				image = _libraw_read_bitmap_data (raw_data->thumbnail.twidth,
+								  raw_data->thumbnail.theight,
+								  raw_data->thumbnail.tcolors,
+								  8,
+								  (guchar *) raw_data->thumbnail.thumb,
+								  raw_data->thumbnail.tlength);
+			} else {
+				g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "Unsupported data format");
+			}
 			break;
 		default:
 			g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "Unsupported data format");
-- 
2.11.1