From ab921f069d2624de547c9a15252fb278de2baf13 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sat, 7 Jan 2017 17:03:34 +0000 Subject: thumbnailer: Update from gnome-thumbnailer-skeleton master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/hadess/gnome-thumbnailer-skeleton/commits/master Add some assertions to help Coverity From looking at the code, these assertions should always hold already, but it clarifies the code and helps static analysis if we add them explicitly. (n_pixels == 0) is only true if (s_x1 == s_x2 || s_y1 == s_y2), which is only true if (dx == 0 || dy == 0). This cannot be true, because dx and dy are the result of dividing source_[width|height] by dest_[width|height], and there’s already an assertion that the former are greater or equal to the latter. Coverity CID: 1388528 https://bugzilla.gnome.org/show_bug.cgi?id=776990 --- thumbnailer/gnome-thumbnailer-skeleton.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'thumbnailer') diff --git a/thumbnailer/gnome-thumbnailer-skeleton.c b/thumbnailer/gnome-thumbnailer-skeleton.c index 10b8d73cb..d686432c2 100644 --- a/thumbnailer/gnome-thumbnailer-skeleton.c +++ b/thumbnailer/gnome-thumbnailer-skeleton.c @@ -88,6 +88,9 @@ gnome_desktop_thumbnail_scale_down_pixbuf (GdkPixbuf *pixbuf, dy = ddy.quot; dy_frac = ddy.rem; + g_assert (dx >= 1); + g_assert (dy >= 1); + has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); source_rowstride = gdk_pixbuf_get_rowstride (pixbuf); src_pixels = gdk_pixbuf_get_pixels (pixbuf); @@ -146,7 +149,9 @@ gnome_desktop_thumbnail_scale_down_pixbuf (GdkPixbuf *pixbuf, } src += source_rowstride; } - + + g_assert (n_pixels > 0); + if (has_alpha) { if (a != 0) { *dest++ = r / a; -- cgit v1.2.1