SDL: Handle potential out of memory condition when working with hints

From ba62ead5ecc111070381c4d32d7b21dfc9bb1493 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 18 Apr 2022 13:45:41 -0700
Subject: [PATCH] Handle potential out of memory condition when working with
 hints

---
 src/SDL_hints.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/SDL_hints.c b/src/SDL_hints.c
index 2eea5501e75..d3fc8ab46ed 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;