comparison src/video/SDL_surface.c @ 940:bb1588ebe47b

Date: Sat, 10 Jul 2004 21:02:33 +0200 From: "Philippe Plantier (ayin)" Subject: [SDL] Problems allocating large surfaces There are problems when allocating large surfaces using SDL_CreateRGBSurface. When, for example, we try to allocate a surface wider than 16384 pixels, the calculation of the pitch overflows; this leads to a surface that has the w and h flags correctly set, but whose "pixels" buffer is too small. That may lead to heap corruption.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Aug 2004 05:29:45 +0000
parents 01cddd0f2efb
children c2f2370ac1e5
comparison
equal deleted inserted replaced
939:c7c04f811994 940:bb1588ebe47b
49 { 49 {
50 SDL_VideoDevice *video = current_video; 50 SDL_VideoDevice *video = current_video;
51 SDL_VideoDevice *this = current_video; 51 SDL_VideoDevice *this = current_video;
52 SDL_Surface *screen; 52 SDL_Surface *screen;
53 SDL_Surface *surface; 53 SDL_Surface *surface;
54
55 /* Make sure the size requested doesn't overflow our datatypes */
56 /* Next time I write a library like SDL, I'll use int for size. :) */
57 if ( width > 16384 || height > 16384 ) {
58 SDL_SetError("Width or height is too large");
59 return(NULL);
60 }
54 61
55 /* Check to see if we desire the surface in video memory */ 62 /* Check to see if we desire the surface in video memory */
56 if ( video ) { 63 if ( video ) {
57 screen = SDL_PublicSurface; 64 screen = SDL_PublicSurface;
58 } else { 65 } else {