Browse Source

wasapi: Fixed memory leak if new audio devices fail to add.

Ryan C. Gordon 1 year ago
parent
commit
5fa7b291d4
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/core/windows/SDL_immdevice.c

+ 4 - 0
src/core/windows/SDL_immdevice.c

@@ -155,6 +155,10 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool iscapture, const char *
         spec.format = SDL_WaveFormatExToSDLFormat((WAVEFORMATEX *)fmt);
 
         device = SDL_AddAudioDevice(iscapture, devname, &spec, handle);
+        if (!device) {
+            SDL_free(handle->immdevice_id);
+            SDL_free(handle);
+        }
     }
 
     return device;