]> mj.ucw.cz Git - libucw.git/commitdiff
fixed segfaulting libjpeg warnings when decoding partially wrong images...
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 24 Nov 2006 23:31:25 +0000 (00:31 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 24 Nov 2006 23:31:25 +0000 (00:31 +0100)
now we reject such images, but it can be easily changed in ifdef

images/io-libjpeg.c

index 03952519ee8542a0af5f49f97e8726592e3d5d1e..144e0b0e0a039f066099d1009513a1f57e18eef4 100644 (file)
@@ -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