diff options
author | Pablo Barciela <[email protected]> | 2019-03-18 01:39:29 +0100 |
---|---|---|
committer | ZenWalker <[email protected]> | 2019-03-25 21:07:10 +0100 |
commit | a4a8e89c52d81aef7072fd3a7c3516a7113562ea (patch) | |
tree | f9f3436565c983b8078df2f1732dc65b8c733564 | |
parent | 1fa41d259b1f37b4ca4ec64cf10d70c6da364850 (diff) | |
download | mate-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;
~~^~~~~~~~~~
-rw-r--r-- | libmate-desktop/mate-thumbnail-pixbuf-utils.c | 12 |
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; |