Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add input validation and null checking to SDL_Get/SetWindowData [repo…

…rted by Joseph T.]
  • Loading branch information
ferzkopp committed Apr 2, 2013
1 parent e10d89c commit 6a10d81cea5ab739871d73e776102624512b0d34
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/video/SDL_video.c
@@ -1425,11 +1425,17 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
SDL_WindowUserData *prev, *data;

CHECK_WINDOW_MAGIC(window, NULL);

/* Input validation */
if (name == NULL || SDL_strlen(name) == 0) {
SDL_InvalidParamError("name");
return NULL;
}

/* See if the named data already exists */
prev = NULL;
for (data = window->data; data; prev = data, data = data->next) {
if (SDL_strcmp(data->name, name) == 0) {
if (data->name && SDL_strcmp(data->name, name) == 0) {
void *last_value = data->data;

if (userdata) {
@@ -1467,8 +1473,14 @@ SDL_GetWindowData(SDL_Window * window, const char *name)

CHECK_WINDOW_MAGIC(window, NULL);

/* Input validation */
if (name == NULL || SDL_strlen(name) == 0) {
SDL_InvalidParamError("name");
return NULL;
}

for (data = window->data; data; data = data->next) {
if (SDL_strcmp(data->name, name) == 0) {
if (data->name && SDL_strcmp(data->name, name) == 0) {
return data->data;
}
}

0 comments on commit 6a10d81

Please sign in to comment.