From ae9047b1ed4485b8f3972052dc98f201906888b4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 3 Mar 2022 19:03:29 +0000 Subject: [PATCH] GIF: Tolerate errors during scan if at least one frame. --- content/handlers/image/gif.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c index 0d4506ab0..49aed73e0 100644 --- a/content/handlers/image/gif.c +++ b/content/handlers/image/gif.c @@ -37,6 +37,7 @@ #include +#include "utils/log.h" #include "utils/utils.h" #include "utils/messages.h" #include "utils/nsoption.h" @@ -211,18 +212,21 @@ static bool gif_convert(struct content *c) /* Initialise the GIF */ gif_err = nsgif_data_scan(gif->gif, size, data); if (gif_err != NSGIF_OK) { - err = gif__nsgif_error_to_ns(gif_err); - content_broadcast_error(c, err, nsgif_strerror(gif_err)); - return false; + NSLOG(netsurf, DEBUG, "%s", nsgif_strerror(gif_err)); + /* Not fatal unless er have no frames. */ } gif_info = nsgif_get_info(gif->gif); assert(gif_info != NULL); /* Abort on bad GIFs */ - if (gif_info->height == 0) { + if (gif_info->frame_count == 0) { err = gif__nsgif_error_to_ns(gif_err); - content_broadcast_error(c, err, "Zero height image."); + content_broadcast_error(c, err, "GIF with no frames."); + return false; + } else if (gif_info->width == 0 || gif_info->height == 0) { + err = gif__nsgif_error_to_ns(gif_err); + content_broadcast_error(c, err, "Zero size image."); return false; }