*** empty log message ***
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Dec 2001 01:55:32 +0000
changeset 61a8a23146b406
parent 60 fd49cc9b9506
child 62 dbc075a7e0b1
*** empty log message ***
CHANGES
IMG_jpg.c
configure.in
     1.1 --- a/CHANGES	Fri Dec 28 14:19:28 2001 +0000
     1.2 +++ b/CHANGES	Sat Dec 29 01:55:32 2001 +0000
     1.3 @@ -1,3 +1,7 @@
     1.4 +
     1.5 +1.2.2:
     1.6 +Mattias Engdegård - Fri Dec 28 17:54:31 PST 2001
     1.7 + * Worked around exit() in the jpeg image library
     1.8  
     1.9  1.2.1:
    1.10  Mattias Engdegård - Tue Nov 20 08:08:53 PST 2001
     2.1 --- a/IMG_jpg.c	Fri Dec 28 14:19:28 2001 +0000
     2.2 +++ b/IMG_jpg.c	Sat Dec 29 01:55:32 2001 +0000
     2.3 @@ -26,6 +26,7 @@
     2.4  
     2.5  #include <stdio.h>
     2.6  #include <string.h>
     2.7 +#include <setjmp.h>
     2.8  
     2.9  #include "SDL_image.h"
    2.10  
    2.11 @@ -171,16 +172,42 @@
    2.12    src->pub.next_input_byte = NULL; /* until buffer loaded */
    2.13  }
    2.14  
    2.15 +struct my_error_mgr {
    2.16 +	struct jpeg_error_mgr errmgr;
    2.17 +	jmp_buf escape;
    2.18 +};
    2.19 +
    2.20 +static void my_error_exit(j_common_ptr cinfo)
    2.21 +{
    2.22 +	struct my_error_mgr *err = (struct my_error_mgr *)cinfo->err;
    2.23 +	longjmp(err->escape, 1);
    2.24 +}
    2.25 +
    2.26 +static void output_no_message(j_common_ptr cinfo)
    2.27 +{
    2.28 +	/* do nothing */
    2.29 +}
    2.30 +
    2.31  /* Load a JPEG type image from an SDL datasource */
    2.32  SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
    2.33  {
    2.34 -	struct jpeg_error_mgr errmgr;
    2.35  	struct jpeg_decompress_struct cinfo;
    2.36  	JSAMPROW rowptr[1];
    2.37 -	SDL_Surface *surface;
    2.38 +	SDL_Surface *volatile surface = NULL;
    2.39 +	struct my_error_mgr jerr;
    2.40  
    2.41  	/* Create a decompression structure and load the JPEG header */
    2.42 -	cinfo.err = jpeg_std_error(&errmgr);
    2.43 +	cinfo.err = jpeg_std_error(&jerr.errmgr);
    2.44 +	jerr.errmgr.error_exit = my_error_exit;
    2.45 +	jerr.errmgr.output_message = output_no_message;
    2.46 +	if(setjmp(jerr.escape)) {
    2.47 +		/* If we get here, libjpeg found an error */
    2.48 +		jpeg_destroy_decompress(&cinfo);
    2.49 +		IMG_SetError("JPEG loading error");
    2.50 +		SDL_FreeSurface(surface);
    2.51 +		return NULL;
    2.52 +	}
    2.53 +
    2.54  	jpeg_create_decompress(&cinfo);
    2.55  	jpeg_SDL_RW_src(&cinfo, src);
    2.56  	jpeg_read_header(&cinfo, TRUE);
     3.1 --- a/configure.in	Fri Dec 28 14:19:28 2001 +0000
     3.2 +++ b/configure.in	Sat Dec 29 01:55:32 2001 +0000
     3.3 @@ -13,9 +13,9 @@
     3.4  
     3.5  MAJOR_VERSION=1
     3.6  MINOR_VERSION=2
     3.7 -MICRO_VERSION=1
     3.8 -INTERFACE_AGE=0
     3.9 -BINARY_AGE=1
    3.10 +MICRO_VERSION=2
    3.11 +INTERFACE_AGE=1
    3.12 +BINARY_AGE=2
    3.13  VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
    3.14  
    3.15  AC_SUBST(MAJOR_VERSION)