]> git.sesse.net Git - ffmpeg/commitdiff
dvbsubdec: fix division by zero in compute_default_clut
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 8 Nov 2016 21:32:42 +0000 (22:32 +0100)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Thu, 10 Nov 2016 20:01:59 +0000 (21:01 +0100)
This problem was introduced in commit
4b90dcb8493552c17a811c8b1e6538dae4061f9d.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavcodec/dvbsubdec.c

index e9f4765b15fe51963cd6cbccdddb3282b95e6c9e..bf3b1a1019e8e6ad8526c85bac2a7592e56b1e06 100644 (file)
@@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
         list_inv[     i ] = bestv;
     }
 
-    count = i - 1;
+    count = FFMAX(i - 1, 1);
     for (i--; i>=0; i--) {
         int v = i*255/count;
         AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));