summaryrefslogtreecommitdiff
path: root/src/video/SDL_pixels.c
diff options
context:
space:
mode:
authorAndreas Schiffler <aschiffler@ferzkopp.net>2013-05-04 09:11:18 -0700
committerAndreas Schiffler <aschiffler@ferzkopp.net>2013-05-04 09:11:18 -0700
commit174b0ff8ef29220926ba3a05b884ff402991a2f0 (patch)
tree10e5334719082fbc6ff63df2d0e3808efeda9cfa /src/video/SDL_pixels.c
parent02819fa478e7021de7ac001fe39089d21ab784f5 (diff)
downloadsdl-174b0ff8ef29220926ba3a05b884ff402991a2f0.tar.gz
Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Diffstat (limited to 'src/video/SDL_pixels.c')
-rw-r--r--src/video/SDL_pixels.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index 84a75b8eb..55e181922 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -503,6 +503,7 @@ SDL_AllocFormat(Uint32 pixel_format)
}
if (SDL_InitFormat(format, pixel_format) < 0) {
SDL_free(format);
+ SDL_InvalidParamError("format");
return NULL;
}
@@ -585,6 +586,7 @@ SDL_FreeFormat(SDL_PixelFormat *format)
SDL_PixelFormat *prev;
if (!format) {
+ SDL_InvalidParamError("format");
return;
}
if (--format->refcount > 0) {
@@ -613,6 +615,12 @@ SDL_Palette *
SDL_AllocPalette(int ncolors)
{
SDL_Palette *palette;
+
+ /* Input validation */
+ if (ncolors < 1) {
+ SDL_InvalidParamError("ncolors");
+ return NULL;
+ }
palette = (SDL_Palette *) SDL_malloc(sizeof(*palette));
if (!palette) {
@@ -693,6 +701,7 @@ void
SDL_FreePalette(SDL_Palette * palette)
{
if (!palette) {
+ SDL_InvalidParamError("palette");
return;
}
if (--palette->refcount > 0) {