From 9d2aef048d4740f497351f2d8029249e1914d837 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 21 Nov 2014 10:05:46 +0100 Subject: ao_oss: check whether setting samplerate succeeds Independent from whether the samplerate was accepted or adjusted, errors returned by the ioctl are fatal errors. Found by Coverity. --- audio/out/ao_oss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 5dc1ea9830..826bb1cf2f 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -322,7 +322,8 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) #endif if (AF_FORMAT_IS_IEC61937(format)) { - ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate); + if (ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate) == -1) + goto fail; // Probably could be fixed by setting number of channels; needs testing. if (channels.num != 2) { MP_ERR(ao, "Format %s not implemented.\n", af_fmt_to_str(format)); @@ -374,7 +375,8 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) MP_VERBOSE(ao, "using %d channels (requested: %d)\n", channels.num, reqchannels); // set rate - ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate); + if (ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate) == -1) + goto fail; MP_VERBOSE(ao, "using %d Hz samplerate\n", samplerate); } -- cgit v1.2.3