summaryrefslogtreecommitdiff
path: root/eel/eel-gdk-pixbuf-extensions.c
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2019-03-03 02:54:35 +0100
committerPablo Barciela <[email protected]>2019-03-06 23:57:45 +0100
commit601c8533a5430055df7af0c723387888ff014c3a (patch)
tree4691d37456967944e96bf0a9db9dcb88e4a2964d /eel/eel-gdk-pixbuf-extensions.c
parent6e6c9c6b456718ba76ecbd2d956f718374ffd3cd (diff)
downloadcaja-601c8533a5430055df7af0c723387888ff014c3a.tar.bz2
caja-601c8533a5430055df7af0c723387888ff014c3a.tar.xz
eel-gdk-pixbuf-extensions: Fix division by zero
Fixes Clang static analyzer warning: eel-gdk-pixbuf-extensions.c:403:29: warning: Division by zero *dest++ = r / n_pixels; ~~^~~~~~~~~~
Diffstat (limited to 'eel/eel-gdk-pixbuf-extensions.c')
-rw-r--r--eel/eel-gdk-pixbuf-extensions.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c
index 646a5734..b74b1062 100644
--- a/eel/eel-gdk-pixbuf-extensions.c
+++ b/eel/eel-gdk-pixbuf-extensions.c
@@ -400,9 +400,18 @@ eel_gdk_pixbuf_scale_down (GdkPixbuf *pixbuf,
}
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;