Bug 112801 - digikarm refuses to start: Unsupported JPEG data precision 12
Summary: digikarm refuses to start: Unsupported JPEG data precision 12
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-JPEG (show other bugs)
Version: 0.8.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-18 00:46 UTC by Jens
Modified: 2022-01-18 16:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.6.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens 2005-09-18 00:46:31 UTC
Version:           0.8.0-beta1 (using KDE 3.4.2 Level "b" , SUSE 10.0)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-9-default

Hello,

when I have a 48-bit JPEG image in my album folder, digikam refuses to start up. On the console, you can read

"Unsupported JPEG data precision 12"

It's probably OK if it does not display  this image but I think it should not completely refuse to start up.

Jens
Comment 1 Renchi Raju 2005-09-18 02:07:11 UTC
SVN commit 461552 by pahlibar:

override default jpeg error handling so that the 
program doesn't bail out on encoutering a rogue jpeg
file
BUGS: 112801


 M  +37 -8     jpegmetadata.cpp  


--- trunk/extragear/graphics/digikam/libs/jpegutils/jpegmetadata.cpp #461551:461552
@@ -19,6 +19,7 @@
  * ============================================================ */
 
 #include <qfile.h>
+#include <kdebug.h>
 #include <libkexif/kexifdata.h>
 
 #include "jpegmetadata.h"
@@ -27,8 +28,28 @@
 extern "C" {
 #include <stdio.h>
 #include <jpeglib.h>
+#include <setjmp.h>
 }         
 
+struct readJPEGMetaData_error_mgr : public jpeg_error_mgr
+{
+    jmp_buf setjmp_buffer;
+};
+
+extern "C"
+{
+    static void readJPEGMetaData_error_exit(j_common_ptr cinfo)
+    {
+        readJPEGMetaData_error_mgr* myerr =
+            (readJPEGMetaData_error_mgr*) cinfo->err;
+
+        char buffer[JMSG_LENGTH_MAX];
+        (*cinfo->err->format_message)(cinfo, buffer);
+        kdWarning() << buffer << endl;
+        longjmp(myerr->setjmp_buffer, 1);
+    }
+}
+
 namespace Digikam
 {
 
@@ -42,18 +63,26 @@
     comments = QString();
     datetime = QDateTime();
 
-    struct jpeg_decompress_struct srcinfo;
-    struct jpeg_error_mgr jsrcerr;
+    FILE *input_file = fopen(QFile::encodeName(filePath), "rb");
+    if (!input_file)
+        return;
+    
+    struct jpeg_decompress_struct     srcinfo;
+    struct readJPEGMetaData_error_mgr jerr;
 
-    srcinfo.err = jpeg_std_error(&jsrcerr);
+    srcinfo.err             = jpeg_std_error(&jerr);
+    srcinfo.err->error_exit = readJPEGMetaData_error_exit;
+
+    if (setjmp(jerr.setjmp_buffer))
+    {
+        jpeg_destroy_decompress(&srcinfo);
+        fclose(input_file);
+        return;
+    }
+    
     jpeg_create_decompress(&srcinfo);
 
-    FILE *input_file;
 
-    input_file = fopen(QFile::encodeName(filePath), "rb");
-    if (!input_file)
-        return;
-
     unsigned short header;
     
     if (fread(&header, 2, 1, input_file) != 1)
Comment 2 Jens 2005-09-18 13:43:52 UTC
Thank you! I was just about to provide a sample image. :-)
You can download it at www.jensbenecke.de/temp/3-11-48bit.jpg