gifsicle/fix_gifdiff_null-deref.patch

43 lines
1.4 KiB
Diff

From 263cd4519f45bc6ecde74ee280eb1d68ee2de642 Mon Sep 17 00:00:00 2001
From: Eddie Kohler <ekohler@gmail.com>
Date: Sat, 2 Dec 2017 23:10:30 -0500
Subject: [PATCH] Two GIFs with zero images are the same.
Another KAIST report; we null-dereferenced previously.
---
src/gifdiff.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/gifdiff.c b/src/gifdiff.c
index 04721d8..40da3c1 100644
--- a/src/gifdiff.c
+++ b/src/gifdiff.c
@@ -248,12 +248,6 @@ compare(Gif_Stream *s1, Gif_Stream *s2)
Gif_CalculateScreenSize(s1, 0);
Gif_CalculateScreenSize(s2, 0);
- if (s1->nimages != s2->nimages
- && (s1->nimages == 0 || s2->nimages == 0)) {
- different("frame counts differ: <#%d >#%d", s1->nimages, s2->nimages);
- return DIFFERENT;
- }
-
if (s1->screen_width != s2->screen_width
|| s1->screen_height != s2->screen_height) {
different("screen sizes differ: <%dx%d >%dx%d", s1->screen_width,
@@ -268,6 +262,14 @@ compare(Gif_Stream *s1, Gif_Stream *s2)
return DIFFERENT;
}
+ if (s1->nimages == 0 || s2->nimages == 0) {
+ if (s1->nimages != s2->nimages) {
+ different("frame counts differ: <#%d >#%d", s1->nimages, s2->nimages);
+ return DIFFERENT;
+ } else
+ return SAME;
+ }
+
/* Create arrays for the image data */
screen_width = s1->screen_width;
screen_height = s1->screen_height;