Преглед изворни кода

Handle potential out of memory condition when working with hints

Sam Lantinga пре 3 година
родитељ
комит
ba62ead5ec
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      src/SDL_hints.c

+ 5 - 0
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;