Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
This commit is contained in:
parent
866f2e5f9e
commit
28d45cd955
2 changed files with 96 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue