aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author"John Hawthorn ext:(%22) <jhawthor@uvic.ca>2008-12-21 20:04:27 -0800
committer"John Hawthorn ext:(%22) <jhawthor@uvic.ca>2008-12-21 20:04:27 -0800
commita4cf4693c3480cc286c68564e1db644556349cee (patch)
tree784e0470144d008fc8c28d2dc77d6d51877fdd09
parent6f208d6c757e03784c768774dfa2fa568444877c (diff)
downloadmirror-meh-a4cf4693c3480cc286c68564e1db644556349cee.tar.gz
mirror-meh-a4cf4693c3480cc286c68564e1db644556349cee.tar.bz2
mirror-meh-a4cf4693c3480cc286c68564e1db644556349cee.zip
no longer exit for unreadable jpeg's
-rw-r--r--src/jpeg.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/jpeg.c b/src/jpeg.c
index 11e9898..93b9f78 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -27,6 +27,12 @@ static void error_exit(j_common_ptr cinfo){
exit(1);
}
+static void error_longjmp(j_common_ptr cinfo){
+ struct error_mgr *myerr = (struct error_mgr *)cinfo->err;
+ (*cinfo->err->output_message)(cinfo);
+ longjmp(myerr->jmp_buffer, 1);
+}
+
static struct image *jpeg_open(FILE *f){
struct jpeg_t *j;
@@ -39,7 +45,10 @@ static struct image *jpeg_open(FILE *f){
rewind(f);
j->cinfo.err = jpeg_std_error(&j->jerr.pub);
- j->jerr.pub.error_exit = error_exit;
+ j->jerr.pub.error_exit = error_longjmp;
+ if (setjmp(j->jerr.jmp_buffer)) {
+ return NULL;
+ }
jpeg_create_decompress(&j->cinfo);
jpeg_stdio_src(&j->cinfo, f);
@@ -56,6 +65,7 @@ static struct image *jpeg_open(FILE *f){
j->img.bufwidth = j->cinfo.output_width;
j->img.bufheight = j->cinfo.output_height;
+ j->jerr.pub.error_exit = error_exit;
return (struct image *)j;
}
@@ -65,6 +75,11 @@ static int jpeg_read(struct image *img){
int a = 0, b;
unsigned int x, y;
+ j->jerr.pub.error_exit = error_longjmp;
+ if(setjmp(j->jerr.jmp_buffer)){
+ return 1; /* ERROR */
+ }
+
row_stride = j->cinfo.output_width * j->cinfo.output_components;
jpeg_start_decompress(&j->cinfo);