Browse Source

Fixed potential wraparound issue with property IDs

Sam Lantinga 1 year ago
parent
commit
b79db0a6ea
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/SDL_properties.c

+ 5 - 1
src/SDL_properties.c

@@ -124,7 +124,11 @@ SDL_PropertiesID SDL_CreateProperties(void)
     }
     }
 
 
     if (SDL_LockRWLockForWriting(SDL_properties_lock) == 0) {
     if (SDL_LockRWLockForWriting(SDL_properties_lock) == 0) {
-        props = ++SDL_last_properties_id;
+        ++SDL_last_properties_id;
+        if (SDL_last_properties_id == 0) {
+            ++SDL_last_properties_id;
+        }
+        props = SDL_last_properties_id;
         if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) {
         if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) {
             inserted = SDL_TRUE;
             inserted = SDL_TRUE;
         }
         }