diff options
author | Pablo Barciela <[email protected]> | 2019-03-18 01:39:29 +0100 |
---|---|---|
committer | Pablo Barciela <[email protected]> | 2019-03-25 21:09:17 +0100 |
commit | 824dd5767c0b41d2c92d5beb63d9e891d50397fd (patch) | |
tree | d5b770075f4cb886b34bf4fc1c58db286a0991c1 | |
parent | cf00858fef7b447e250371588359b72fa535733e (diff) | |
download | mate-desktop-824dd5767c0b41d2c92d5beb63d9e891d50397fd.tar.bz2 mate-desktop-824dd5767c0b41d2c92d5beb63d9e891d50397fd.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; |