aboutsummaryrefslogtreecommitdiff
path: root/src/opus_multistream_encoder.c
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-04 01:29:23 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-04 01:29:23 -0400
commit328953e1896432bc700b9b5c69ae2987c5d752f4 (patch)
tree10f574c6f6e3c42644728f352747ce97d78171ea /src/opus_multistream_encoder.c
parentf6f8487b76f234437e7d4c2831e630d9d06cb074 (diff)
downloadlibopus-328953e1896432bc700b9b5c69ae2987c5d752f4.tar.gz
Making calls to opus_packet_pad() on a bad packet return OPUS_INVALID_PACKET
We were previously returning OPUS_BAD_ARG because the failure was only detected in opus_repacketizer_out_range_impl() rather than in opus_repacketizer_cat(). Checking the return value from opus_repacketizer_cat() also addresses the last outstanding Coverity defect.
Diffstat (limited to 'src/opus_multistream_encoder.c')
-rw-r--r--src/opus_multistream_encoder.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c
index 9a7ea95e..389a8477 100644
--- a/src/opus_multistream_encoder.c
+++ b/src/opus_multistream_encoder.c
@@ -968,6 +968,7 @@ static int opus_multistream_encode_native
int len;
int curr_max;
int c1, c2;
+ int ret;
opus_repacketizer_init(&rp);
enc = (OpusEncoder*)ptr;
@@ -1027,7 +1028,11 @@ static int opus_multistream_encode_native
/* We need to use the repacketizer to add the self-delimiting lengths
while taking into account the fact that the encoder can now return
more than one frame at a time (e.g. 60 ms CELT-only) */
- opus_repacketizer_cat(&rp, tmp_data, len);
+ ret = opus_repacketizer_cat(&rp, tmp_data, len);
+ /* If the opus_repacketizer_cat() fails, then something's seriously wrong
+ with the encoder. */
+ if (ret != OPUS_OK)
+ return OPUS_INTERNAL_ERROR;
len = opus_repacketizer_out_range_impl(&rp, 0, opus_repacketizer_get_nb_frames(&rp),
data, max_data_bytes-tot_size, s != st->layout.nb_streams-1, !vbr && s == st->layout.nb_streams-1);
data += len;