summaryrefslogtreecommitdiff
path: root/src/lib/emile
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-04-15 10:44:02 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-04-15 10:49:43 +0900
commit755b290404fa8936c421dc972cf60dc419f5500c (patch)
treef0d99855f7d1bcd0dd1a13c76bf2dd3d59ac26a5 /src/lib/emile
parent1aa26c644f1fa63ed96ba2791ec661fe4d4fa33a (diff)
Emile: Reduce ERR logs on invalid JPEG images
When reading the head of a file, we may get the error that it is not a JPEG image (which is normal), so we should not print any ERR. The JPEG header read function can indeed be called to test whether a file can be opened by the JPEG loader or not (any file). Note that JPEG files don't have reliable magic numbers, so we don't check them, but rely on libjpeg instead. Fixes T2290
Diffstat (limited to 'src/lib/emile')
-rw-r--r--src/lib/emile/emile_image.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/emile/emile_image.c b/src/lib/emile/emile_image.c
index 9ea45396b7..dc8af2c196 100644
--- a/src/lib/emile/emile_image.c
+++ b/src/lib/emile/emile_image.c
@@ -23,6 +23,7 @@
23#include <stdio.h> 23#include <stdio.h>
24#include <setjmp.h> 24#include <setjmp.h>
25#include <jpeglib.h> 25#include <jpeglib.h>
26#include <jerror.h>
26 27
27#ifdef HAVE_EVIL 28#ifdef HAVE_EVIL
28#include <Evil.h> 29#include <Evil.h>
@@ -673,8 +674,12 @@ _emile_image_jpeg_error_exit_cb(j_common_ptr cinfo)
673 char buffer[JMSG_LENGTH_MAX]; 674 char buffer[JMSG_LENGTH_MAX];
674 emptr errmgr; 675 emptr errmgr;
675 676
676 (*cinfo->err->format_message)(cinfo, buffer); 677 // Avoid message "Not a JPEG file: starts with 0x%02x 0x%02x"
677 ERR("%s", buffer); 678 if (cinfo->client_data || (cinfo->err->msg_code != JERR_NO_SOI))
679 {
680 (*cinfo->err->format_message)(cinfo, buffer);
681 ERR("%s", buffer);
682 }
678 errmgr = (emptr)cinfo->err; 683 errmgr = (emptr)cinfo->err;
679 longjmp(errmgr->setjmp_buffer, 1); 684 longjmp(errmgr->setjmp_buffer, 1);
680} 685}
@@ -1352,6 +1357,7 @@ _emile_jpeg_head(Emile_Image *image,
1352 1357
1353 memset(&cinfo, 0, sizeof(cinfo)); 1358 memset(&cinfo, 0, sizeof(cinfo));
1354 cinfo.err = jpeg_std_error(&(jerr.pub)); 1359 cinfo.err = jpeg_std_error(&(jerr.pub));
1360 cinfo.client_data = NULL;
1355 jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb; 1361 jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb;
1356 jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb; 1362 jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb;
1357 jerr.pub.output_message = _emile_image_jpeg_output_message_cb; 1363 jerr.pub.output_message = _emile_image_jpeg_output_message_cb;
@@ -1610,6 +1616,7 @@ _emile_jpeg_data(Emile_Image *image,
1610 } 1616 }
1611 1617
1612 cinfo.err = jpeg_std_error(&(jerr.pub)); 1618 cinfo.err = jpeg_std_error(&(jerr.pub));
1619 cinfo.client_data = (void *)(intptr_t) 0x1;
1613 jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb; 1620 jerr.pub.error_exit = _emile_image_jpeg_error_exit_cb;
1614 jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb; 1621 jerr.pub.emit_message = _emile_image_jpeg_emit_message_cb;
1615 jerr.pub.output_message = _emile_image_jpeg_output_message_cb; 1622 jerr.pub.output_message = _emile_image_jpeg_output_message_cb;