Skip to content

Commit

Permalink
Fixed bug 2205 - SDL_GetAudioDeviceName returns default-device name o…
Browse files Browse the repository at this point in the history
…n invalid index for default-device only drivers

norfanin

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.
  • Loading branch information
slouken committed Nov 3, 2013
1 parent aaa4165 commit 517886a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/audio/SDL_audio.c
Expand Up @@ -722,10 +722,16 @@ SDL_GetAudioDeviceName(int index, int iscapture)
}

if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
if (index > 0) {
goto no_such_device;
}
return DEFAULT_INPUT_DEVNAME;
}

if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
if (index > 0) {
goto no_such_device;
}
return DEFAULT_OUTPUT_DEVNAME;
}

Expand Down

0 comments on commit 517886a

Please sign in to comment.