Browse Source

Always enable object validation when checking is explicitly enabled

Sam Lantinga 1 week ago
parent
commit
33c849d030
2 changed files with 6 additions and 1 deletions
  1. 2 0
      src/SDL_internal.h
  2. 4 1
      src/SDL_utils.c

+ 2 - 0
src/SDL_internal.h

@@ -291,11 +291,13 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
 // If you define SDL_DISABLE_INVALID_PARAMS, you're promising that you'll
 // never pass an invalid parameter to SDL, since it may crash or lead to
 // hard to diagnose bugs. Let's assert that this is true in debug builds.
+#define OBJECT_VALIDATION_REQUIRED
 #define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (false)
 #else
 #define CHECK_PARAM(invalid) if (false)
 #endif
 #elif defined(SDL_ASSERT_INVALID_PARAMS)
+#define OBJECT_VALIDATION_REQUIRED
 #define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (invalid)
 #else
 #define CHECK_PARAM(invalid) if (invalid)

+ 4 - 1
src/SDL_utils.c

@@ -137,12 +137,13 @@ Uint32 SDL_GetNextObjectID(void)
 
 static SDL_InitState SDL_objects_init;
 static SDL_HashTable *SDL_objects;
-bool SDL_object_validation = false;
+bool SDL_object_validation = true;
 
 static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
 {
     bool validation_enabled = true;
 
+#ifndef OBJECT_VALIDATION_REQUIRED
     if (hint) {
         switch (*hint) {
         case '0':
@@ -156,6 +157,8 @@ static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *na
             break;
         }
     }
+#endif // !OBJECT_VALIDATION_REQUIRED
+
     SDL_object_validation = validation_enabled;
 }