From 8b1cd25ca7e64e6128fa2902d78e48bfeeec9786 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 28 Feb 2012 07:19:37 +0100 Subject: [PATCH] pmpdec: Check for zero audio packets. This fixes a division by 0. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavformat/pmpdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c index 4ef8ca3437..315e58c184 100644 --- a/libavformat/pmpdec.c +++ b/libavformat/pmpdec.c @@ -124,6 +124,10 @@ static int pmp_packet(AVFormatContext *s, AVPacket *pkt) if (pmp->cur_stream == 0) { int num_packets; pmp->audio_packets = avio_r8(pb); + if (!pmp->audio_packets) { + av_log_ask_for_sample(s, "0 audio packets\n"); + return AVERROR_PATCHWELCOME; + } num_packets = (pmp->num_streams - 1) * pmp->audio_packets + 1; avio_skip(pb, 8); pmp->current_packet = 0;