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 - SDL_GetAudioDeviceName returns default-device name on invalid index for default-device only drivers
Summary: SDL_GetAudioDeviceName returns default-device name on invalid index for defau...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 minor
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-03 02:40 UTC by norfanin
Modified: 2013-11-03 19:14 UTC (History)
0 users

See Also:


Attachments
Adds a range check for a positive out-of-range index to DL_GetAudioDeviceName. (581 bytes, patch)
2013-11-03 02:42 UTC, norfanin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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