Skip to content

Commit dfd5ca9

Browse files
committed
wasapi: fix memory leak on unlikely failure case.
1 parent bcfac0f commit dfd5ca9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/core/windows/SDL_immdevice.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,16 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn
173173
return NULL;
174174
}
175175

176-
SDL_memcpy(&recording_handle->directsound_guid, dsoundguid, sizeof(GUID));
177176
recording_handle->immdevice_id = SDL_wcsdup(devid);
177+
if (!recording_handle->immdevice_id) {
178+
SDL_free(recording_handle);
179+
return NULL;
180+
}
181+
182+
SDL_copyp(&recording_handle->directsound_guid, &dsoundguid);
178183

179-
if (!recording_handle->immdevice_id || !SDL_AddAudioDevice(true, devname, &spec, recording_handle)) {
184+
if (!SDL_AddAudioDevice(true, devname, &spec, recording_handle)) {
185+
SDL_free(recording_handle->immdevice_id);
180186
SDL_free(recording_handle);
181187
}
182188
}

0 commit comments

Comments
 (0)