From: John Stebbins Date: Fri, 6 Nov 2015 21:00:14 +0000 (-0800) Subject: decavcodec: fix hang in avcodec decoder X-Git-Tag: 0.10.3~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f80c1780b368358c3b7af48cdaeaedb225556ddd;p=handbrake decavcodec: fix hang in avcodec decoder libavcodec/mpeg12dec.c expects input buffers to be zero padded to 32 bit alignment. If not zero padded, it can get caught in an infinite loop. (cherry picked from commit f7b0c5773abe43b003295ecf631c83cc43a1ee91) --- diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 2029aa21d..8c732c6d7 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -537,6 +537,14 @@ static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_work_private_t * pv = w->private_data; hb_buffer_t * in = *buf_in; + // libavcodec/mpeg12dec.c requires buffers to be zero padded. + // If not zero padded, it can get stuck in an infinite loop. + // It's likely there are other decoders that expect the same. + if (in->data != NULL) + { + memset(in->data + in->size, 0, in->alloc - in->size); + } + if ( in->size <= 0 ) { /* EOF on input stream - send it downstream & say that we're done */ @@ -1810,6 +1818,14 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in, *buf_in = NULL; *buf_out = NULL; + // libavcodec/mpeg12dec.c requires buffers to be zero padded. + // If not zero padded, it can get stuck in an infinite loop. + // It's likely there are other decoders that expect the same. + if (in->data != NULL) + { + memset(in->data + in->size, 0, in->alloc - in->size); + } + /* if we got an empty buffer signaling end-of-stream send it downstream */ if ( in->size == 0 ) {