If the packet starts with an END tag, no elemets are decoded and a frame
is never allocated, so we should not return the frame to the user.
---
libavcodec/alac.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index f972531..b49ddd0 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -402,11 +402,11 @@ static int alac_decode_frame(AVCodecContext *avctx, void
*data,
AVFrame *frame = data;
enum AlacRawDataBlockType element;
int channels;
- int ch, ret, got_end;
+ int ch, ret, got_end, got_element;
init_get_bits(&alac->gb, avpkt->data, avpkt->size * 8);
- got_end = 0;
+ got_end = got_element = 0;
alac->nb_samples = 0;
ch = 0;
while (get_bits_left(&alac->gb) >= 3) {
@@ -432,6 +432,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void
*data,
channels);
if (ret < 0 && get_bits_left(&alac->gb))
return ret;
+ got_element = 1;
ch += channels;
}
@@ -439,6 +440,10 @@ static int alac_decode_frame(AVCodecContext *avctx, void
*data,
av_log(avctx, AV_LOG_ERROR, "no end tag found. incomplete packet.\n");
return AVERROR_INVALIDDATA;
}
+ if (!got_element) {
+ av_log(avctx, AV_LOG_ERROR, "no audio elements found in packet.\n");
+ return AVERROR_INVALIDDATA;
+ }
if (avpkt->size * 8 - get_bits_count(&alac->gb) > 8) {
av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n",
--
1.8.1.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel