diff --git a/pipi/codec/jpeg.c b/pipi/codec/jpeg.c index 4b08471..2c7e77a 100644 --- a/pipi/codec/jpeg.c +++ b/pipi/codec/jpeg.c @@ -68,13 +68,13 @@ pipi_image_t *pipi_load_jpeg(const char *name) unsigned int i, j, k = 0; FILE *fp; - if(setjmp(jerr.setjmp_buffer)) - return NULL; - fp = fopen(name, "rb"); if(!fp) return NULL; + if(setjmp(jerr.setjmp_buffer)) + goto end; + cinfo.err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = error_msg; jerr.pub.emit_message = emit_msg;