From a4a8e89c52d81aef7072fd3a7c3516a7113562ea Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Mon, 18 Mar 2019 01:39:29 +0100 Subject: mate-thumbnail-pixbuf-utils: Fix division by zero Fixes Clang static analyzer warning: mate-thumbnail-pixbuf-utils.c:160:17: warning: Division by zero *dest++ = r / n_pixels; ~~^~~~~~~~~~ --- libmate-desktop/mate-thumbnail-pixbuf-utils.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libmate-desktop') diff --git a/libmate-desktop/mate-thumbnail-pixbuf-utils.c b/libmate-desktop/mate-thumbnail-pixbuf-utils.c index b568650..0252c2d 100644 --- a/libmate-desktop/mate-thumbnail-pixbuf-utils.c +++ b/libmate-desktop/mate-thumbnail-pixbuf-utils.c @@ -157,9 +157,15 @@ mate_desktop_thumbnail_scale_down_pixbuf (GdkPixbuf *pixbuf, *dest++ = 0; } } else { - *dest++ = r / n_pixels; - *dest++ = g / n_pixels; - *dest++ = b / n_pixels; + if (n_pixels != 0) { + *dest++ = r / n_pixels; + *dest++ = g / n_pixels; + *dest++ = b / n_pixels; + } else { + *dest++ = 0; + *dest++ = 0; + *dest++ = 0; + } } s_x1 = s_x2; -- cgit v1.2.1