From b54a311fe24c08c6b2900ab8b3d9ebd2f9e95231 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Tue, 21 Jul 2015 13:16:44 -0400 Subject: [PATCH] Bug 1184009 - Limit image preview sizes. r=acomminos --- widget/gtk/nsFilePicker.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp index b63e12bf0d42..9e5394db803f 100644 --- a/widget/gtk/nsFilePicker.cpp +++ b/widget/gtk/nsFilePicker.cpp @@ -101,13 +101,16 @@ UpdateFilePreviewWidget(GtkFileChooser *file_chooser, return; } - GdkPixbuf *preview_pixbuf; + GdkPixbuf *preview_pixbuf = nullptr; // Only scale down images that are too big if (preview_width > MAX_PREVIEW_SIZE || preview_height > MAX_PREVIEW_SIZE) { - preview_pixbuf = gdk_pixbuf_new_from_file_at_size(image_filename, - MAX_PREVIEW_SIZE, - MAX_PREVIEW_SIZE, - nullptr); + if (ceil(preview_width / double(MAX_PREVIEW_SIZE) + 1.0) * + ceil(preview_height / double(MAX_PREVIEW_SIZE) + 1.0) < 0x7FFFFF) { + preview_pixbuf = gdk_pixbuf_new_from_file_at_size(image_filename, + MAX_PREVIEW_SIZE, + MAX_PREVIEW_SIZE, + nullptr); + } } else { preview_pixbuf = gdk_pixbuf_new_from_file(image_filename, nullptr);