comparison src/video/SDL_video.c @ 944:cdea7cbc3e23

Date: Wed, 28 Jul 2004 14:56:57 +0800 From: Aaron Perez Subject: [SDL] Fwd: SDL not checking malloc returning NULL I was reading through the code and i found that in several places does a malloc and without checking if it is NULL just use the pointer.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Aug 2004 13:10:58 +0000
parents 46916168361d
children 475166d13b44
comparison
equal deleted inserted replaced
943:715c32d8f26c 944:cdea7cbc3e23
1273 return gotall; /* video not yet initialized */ 1273 return gotall; /* video not yet initialized */
1274 if(!video->physpal && !(which & SDL_LOGPAL) ) { 1274 if(!video->physpal && !(which & SDL_LOGPAL) ) {
1275 /* Lazy physical palette allocation */ 1275 /* Lazy physical palette allocation */
1276 int size; 1276 int size;
1277 SDL_Palette *pp = malloc(sizeof(*pp)); 1277 SDL_Palette *pp = malloc(sizeof(*pp));
1278 if ( !pp ) {
1279 return 0;
1280 }
1278 current_video->physpal = pp; 1281 current_video->physpal = pp;
1279 pp->ncolors = pal->ncolors; 1282 pp->ncolors = pal->ncolors;
1280 size = pp->ncolors * sizeof(SDL_Color); 1283 size = pp->ncolors * sizeof(SDL_Color);
1281 pp->colors = malloc(size); 1284 pp->colors = malloc(size);
1285 if ( !pp->colors ) {
1286 return 0;
1287 }
1282 memcpy(pp->colors, pal->colors, size); 1288 memcpy(pp->colors, pal->colors, size);
1283 } 1289 }
1284 if ( ! SetPalette_physical(screen, 1290 if ( ! SetPalette_physical(screen,
1285 colors, firstcolor, ncolors) ) { 1291 colors, firstcolor, ncolors) ) {
1286 gotall = 0; 1292 gotall = 0;