From f2cee06708455213f044c4845087508369356e10 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 18 Jun 2012 15:43:28 -0700 Subject: [PATCH] Fix floating point exception with cwebp -progress Adds a test of enc->mb_h_ to VP8IteratorProgress() to avoid a division by zero. Fixes issue #121. Original patch from even rouault (even dot rouault at gmail dot com). Change-Id: Ie5fcc1821860c0a9366d5aa11f3aded4f5b98ed7 --- src/enc/iterator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/enc/iterator.c b/src/enc/iterator.c index c1aa3abe..86e473bc 100644 --- a/src/enc/iterator.c +++ b/src/enc/iterator.c @@ -72,7 +72,9 @@ void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { VP8Encoder* const enc = it->enc_; if (delta && enc->pic_->progress_hook) { - const int percent = it->percent0_ + delta * it->y_ / (enc->mb_h_ - 1); + const int percent = (enc->mb_h_ <= 1) + ? it->percent0_ + : it->percent0_ + delta * it->y_ / (enc->mb_h_ - 1); return WebPReportProgress(enc->pic_, percent, &enc->percent_); } return 1;