summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2019-03-18 01:39:29 +0100
committerZenWalker <[email protected]>2019-03-25 21:07:10 +0100
commita4a8e89c52d81aef7072fd3a7c3516a7113562ea (patch)
treef9f3436565c983b8078df2f1732dc65b8c733564 /libmate-desktop
parent1fa41d259b1f37b4ca4ec64cf10d70c6da364850 (diff)
downloadmate-desktop-a4a8e89c52d81aef7072fd3a7c3516a7113562ea.tar.bz2
mate-desktop-a4a8e89c52d81aef7072fd3a7c3516a7113562ea.tar.xz
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; ~~^~~~~~~~~~
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/mate-thumbnail-pixbuf-utils.c12
1 files changed, 9 insertions, 3 deletions
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;