src/video/SDL_stretch.c
branchSDL-1.2
changeset 4543 d7cdc25af9a2
parent 4541 abb56f7699ea
child 6137 4720145f848b
     1.1 --- a/src/video/SDL_stretch.c	Sun Jul 18 10:08:06 2010 -0700
     1.2 +++ b/src/video/SDL_stretch.c	Sun Jul 18 10:28:57 2010 -0700
     1.3 @@ -78,7 +78,7 @@
     1.4  
     1.5  	int i;
     1.6  	int pos, inc;
     1.7 -	unsigned char *eip, *end;
     1.8 +	unsigned char *eip, *fence;
     1.9  	unsigned char load, store;
    1.10  
    1.11  	/* See if we need to regenerate the copy buffer */
    1.12 @@ -115,15 +115,21 @@
    1.13  	pos = 0x10000;
    1.14  	inc = (src_w << 16) / dst_w;
    1.15  	eip = copy_row;
    1.16 -	end = copy_row+sizeof(copy_row);
    1.17 +	fence = copy_row+sizeof(copy_row)-2;
    1.18  	for ( i=0; i<dst_w && eip < end; ++i ) {
    1.19  		while ( pos >= 0x10000L ) {
    1.20 +			if ( eip == fence ) {
    1.21 +				return -1;
    1.22 +			}
    1.23  			if ( bpp == 2 ) {
    1.24  				*eip++ = PREFIX16;
    1.25  			}
    1.26  			*eip++ = load;
    1.27  			pos -= 0x10000L;
    1.28  		}
    1.29 +		if ( eip == fence ) {
    1.30 +			return -1;
    1.31 +		}
    1.32  		if ( bpp == 2 ) {
    1.33  			*eip++ = PREFIX16;
    1.34  		}
    1.35 @@ -132,11 +138,6 @@
    1.36  	}
    1.37  	*eip++ = RETURN;
    1.38  
    1.39 -	/* Verify that we didn't overflow (too late!!!) */
    1.40 -	if ( i < dst_w ) {
    1.41 -		SDL_SetError("Copy buffer too small");
    1.42 -		return(-1);
    1.43 -	}
    1.44  #ifdef HAVE_MPROTECT
    1.45  	/* Make the code executable but not writeable */
    1.46  	if ( mprotect(copy_row, sizeof(copy_row), PROT_READ|PROT_EXEC) < 0 ) {