From: Pavel Charvat Date: Fri, 24 Nov 2006 23:31:25 +0000 (+0100) Subject: fixed segfaulting libjpeg warnings when decoding partially wrong images... X-Git-Tag: holmes-import~507^2~23^2~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=403cbecdeaf3cd76c845205c52818e4c6a64c15e;p=libucw.git fixed segfaulting libjpeg warnings when decoding partially wrong images... now we reject such images, but it can be easily changed in ifdef --- diff --git a/images/io-libjpeg.c b/images/io-libjpeg.c index 03952519..144e0b0e 100644 --- a/images/io-libjpeg.c +++ b/images/io-libjpeg.c @@ -75,8 +75,17 @@ libjpeg_emit_message(j_common_ptr cinfo UNUSED, int msg_level UNUSED) cinfo->err->format_message(cinfo, buf); DBG("libjpeg_emit_message(): [%d] %s", msg_level, buf); #endif +#if 1 + // Terminate on warning? if (unlikely(msg_level == -1)) - longjmp(((struct libjpeg_err *)(cinfo)->err)->setjmp_buf, 1); + { + struct libjpeg_err *e = (struct libjpeg_err *)cinfo->err; + byte buf[JMSG_LENGTH_MAX]; + cinfo->err->format_message(cinfo, buf); + IMAGE_ERROR(e->io->context, 0, "libjpeg: %s", buf); + longjmp(e->setjmp_buf, 1); + } +#endif } static inline uns