diff 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
line wrap: on
line diff
--- a/src/video/SDL_video.c	Sat Aug 21 12:38:50 2004 +0000
+++ b/src/video/SDL_video.c	Sat Aug 21 13:10:58 2004 +0000
@@ -1275,10 +1275,16 @@
 			/* Lazy physical palette allocation */
 			int size;
 			SDL_Palette *pp = malloc(sizeof(*pp));
+			if ( !pp ) {
+				return 0;
+			}
 			current_video->physpal = pp;
 			pp->ncolors = pal->ncolors;
 			size = pp->ncolors * sizeof(SDL_Color);
 			pp->colors = malloc(size);
+			if ( !pp->colors ) {
+				return 0;
+			}
 			memcpy(pp->colors, pal->colors, size);
 		}
 		if ( ! SetPalette_physical(screen,