Handle potential out of memory condition when working with hints

main
Sam Lantinga 2022-04-18 13:45:41 -07:00
parent 145824f6ab
commit ba62ead5ec
1 changed files with 5 additions and 0 deletions

View File

@ -178,6 +178,11 @@ SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
return;
}
hint->name = SDL_strdup(name);
if (!hint->name) {
SDL_free(hint);
SDL_OutOfMemory();
return;
}
hint->value = NULL;
hint->priority = SDL_HINT_DEFAULT;
hint->callbacks = NULL;