We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2205

Summary: SDL_GetAudioDeviceName returns default-device name on invalid index for default-device only drivers
Product: SDL Reporter: norfanin
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   
Attachments: Adds a range check for a positive out-of-range index to DL_GetAudioDeviceName.

Description norfanin 2013-11-03 02:40:32 UTC
The audio_enumerateAndNameAudioDevicesNegativeTests test in testautomation_audio.c reports a failure for SDL_GetAudioDeviceName when called on a driver that has only the default device. SDL_GetNumAudioDevices reports 1, but SDL_GetAudioDeviceName does not check if the index passed by the caller is in that range in this case. For positive numbers anyway.

This can be reproduced with the dummy driver on Windows and Linux.
Comment 1 norfanin 2013-11-03 02:42:11 UTC
Created attachment 1401 [details]
Adds a range check for a positive out-of-range index to DL_GetAudioDeviceName.

I don't know if this is okay with other drivers, but I'll just throw this patch in here that adds a range check.
Comment 2 Sam Lantinga 2013-11-03 19:14:34 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/915b9b6c9fa0