Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2013-06-30 07:06:07 +0400
committerGregory Maxwell <greg@xiph.org>2013-06-30 07:06:07 +0400
commitdd7b0dac3ba85cda7e314eaa867b4f0d716c9ac4 (patch)
tree91fe0be58c357fc082d9323f3d99c387dc9fec1d /src/opus_decoder.c
parent90a39039a46040faa944b4690c16452a088016e2 (diff)
Fixes some return without va_end in the api, adds tests.
Also makes the CTL bad argument handling more consistent to avoid mistakes like that in the future. Also updates the variable duration docs.
Diffstat (limited to 'src/opus_decoder.c')
-rw-r--r--src/opus_decoder.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 6bc70919..13a910f4 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -937,12 +937,14 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
case OPUS_GET_BANDWIDTH_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*);
+ if (!value) goto bad_arg;
*value = st->bandwidth;
}
break;
case OPUS_GET_FINAL_RANGE_REQUEST:
{
opus_uint32 *value = va_arg(ap, opus_uint32*);
+ if (!value) goto bad_arg;
*value = st->rangeFinal;
}
break;
@@ -961,22 +963,14 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
case OPUS_GET_SAMPLE_RATE_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*);
- if (value==NULL)
- {
- ret = OPUS_BAD_ARG;
- break;
- }
+ if (!value) goto bad_arg;
*value = st->Fs;
}
break;
case OPUS_GET_PITCH_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*);
- if (value==NULL)
- {
- ret = OPUS_BAD_ARG;
- break;
- }
+ if (!value) goto bad_arg;
if (st->prev_mode == MODE_CELT_ONLY)
celt_decoder_ctl(celt_dec, OPUS_GET_PITCH(value));
else
@@ -986,28 +980,21 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
case OPUS_GET_GAIN_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*);
- if (value==NULL)
- {
- ret = OPUS_BAD_ARG;
- break;
- }
+ if (!value) goto bad_arg;
*value = st->decode_gain;
}
break;
case OPUS_SET_GAIN_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
- if (value<-32768 || value>32767)
- {
- ret = OPUS_BAD_ARG;
- break;
- }
+ if (value<-32768 || value>32767) goto bad_arg;
st->decode_gain = value;
}
break;
case OPUS_GET_LAST_PACKET_DURATION_REQUEST:
{
opus_uint32 *value = va_arg(ap, opus_uint32*);
+ if (!value) goto bad_arg;
*value = st->last_packet_duration;
}
break;
@@ -1019,6 +1006,9 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
va_end(ap);
return ret;
+bad_arg:
+ va_end(ap);
+ return OPUS_BAD_ARG;
}
void opus_decoder_destroy(OpusDecoder *st)