Commit ba62ead5ecc111070381c4d32d7b21dfc9bb1493

Sam Lantinga 2022-04-18T13:45:41

Handle potential out of memory condition when working with hints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/SDL_hints.c b/src/SDL_hints.c
index 2eea550..d3fc8ab 100644
--- a/src/SDL_hints.c
+++ b/src/SDL_hints.c
@@ -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;