diff mbox

[FFmpeg-devel,2/2] wmavoice: prevent division by zero crash

Message ID ca829ea2-386a-ff6e-e93e-66843061a1ae@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Jan. 1, 2017, 10:19 p.m. UTC
The problem was introduced by commit
3deb4b54a24f8cddce463d9f5751b01efeb976af.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/wmavoice.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ronald S. Bultje Jan. 1, 2017, 10:23 p.m. UTC | #1
Hi,

On Sun, Jan 1, 2017 at 5:19 PM, Andreas Cadhalpun <
andreas.cadhalpun@googlemail.com> wrote:

> The problem was introduced by commit
> 3deb4b54a24f8cddce463d9f5751b01efeb976af.
>
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavcodec/wmavoice.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
> index 1bfad46b2e..279b44dc12 100644
> --- a/libavcodec/wmavoice.c
> +++ b/libavcodec/wmavoice.c
> @@ -1908,7 +1908,7 @@ static int wmavoice_decode_packet(AVCodecContext
> *ctx, void *data,
>      /* size == ctx->block_align is used to indicate whether we are
> dealing with
>       * a new packet or a packet of which we already read the packet header
>       * previously. */
> -    if (!(size % ctx->block_align)) { // new packet header
> +    if (ctx->block_align && !(size % ctx->block_align)) { // new packet
> header
>          if (!size) {
>              s->spillover_nbits = 0;
>              s->nb_superframes = 0;
> --
> 2.11.0


nak.

The init routine should error out if block_align is zero. The codec can not
operate without block_align set.

Ronald
diff mbox

Patch

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 1bfad46b2e..279b44dc12 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -1908,7 +1908,7 @@  static int wmavoice_decode_packet(AVCodecContext *ctx, void *data,
     /* size == ctx->block_align is used to indicate whether we are dealing with
      * a new packet or a packet of which we already read the packet header
      * previously. */
-    if (!(size % ctx->block_align)) { // new packet header
+    if (ctx->block_align && !(size % ctx->block_align)) { // new packet header
         if (!size) {
             s->spillover_nbits = 0;
             s->nb_superframes = 0;