[gdk-pixbuf] ico: Avoid possible ImageScore overflow
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] ico: Avoid possible ImageScore overflow
- Date: Tue, 18 Jul 2017 13:34:38 +0000 (UTC)
commit 99508c712d50e691328f47ce137cdbfa48b2d2e7
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jul 13 22:05:36 2017 +0200
ico: Avoid possible ImageScore overflow
Seeing as this is only a comparison, don't try to do arithmetics that
could overflow.
Detected by UBSan:
io-ico.c:204:9: runtime error: signed integer overflow: 2134193699 -
-555819298 cannot be represented in type 'int'
https://bugzilla.gnome.org/show_bug.cgi?id=776040
gdk-pixbuf/io-ico.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index ddb804c..9e5cce2 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -203,7 +203,11 @@ compare_direntry_scores (gconstpointer a,
const struct ico_direntry_data *ib = b;
/* Backwards, so largest first */
- return ib->ImageScore - ia->ImageScore;
+ if (ib->ImageScore > ia->ImageScore)
+ return -1;
+ else if (ib->ImageScore < ia->ImageScore)
+ return 1;
+ return 0;
}
static void DecodeHeader(guchar *Data, gint Bytes,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]