From patchwork Tue Nov 8 21:36:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1348 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1917972vsb; Tue, 8 Nov 2016 13:36:12 -0800 (PST) X-Received: by 10.28.149.135 with SMTP id x129mr13103297wmd.71.1478640971998; Tue, 08 Nov 2016 13:36:11 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i6si18796432wmf.38.2016.11.08.13.36.11; Tue, 08 Nov 2016 13:36:11 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@googlemail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C079689A8F; Tue, 8 Nov 2016 23:36:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB2A76899D0 for ; Tue, 8 Nov 2016 23:35:59 +0200 (EET) Received: by mail-wm0-f67.google.com with SMTP id c17so25263922wmc.3 for ; Tue, 08 Nov 2016 13:36:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=yN+dCN/pFE6Mv7e+HjCMomSbYzmf/elg+B2ms6+fSZw=; b=GyyXuBL06LXOxMVtIGx/FZrLlpDW9iiB5jSls/h4/wUs214FGz6SO43F/ZNm/mq46V gtUdaVHYhsAJA4vNA8gyUgG6yKjI7JRHzuPyZubyCGVR83QRrW7eHsR1Br7wX7Ituq0W LsIPkNo4GqgqMEpetjs0iCRnQ4cSQy3MIKPFQSWrCsp2Z42b14TxsLMpArLdY7zYOKNG /isCLQyuo26gzU+uETSuEirCiDWqJ/wtXCZRYujeudN+sPdrMtbnRlm1JQaVcVs7mJ50 6r0qOdvkHAVXAaGuQNBV0dM1J//SFczF2/EDfZfiWNZy8kxuSV4Zo/xcnbwR0UPPEeqE GMAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=yN+dCN/pFE6Mv7e+HjCMomSbYzmf/elg+B2ms6+fSZw=; b=cArrwZx1hTo1knCR/vbYPymBZzrtY5alOPhP4K8J36HkXWWkAXYDLNa6s+48CY2Lht CPazkaE1eOKE5LySj1K7cKpyoP626HGgsH+KT1b2KqDPKIkzwNBXPQvX7aSLLrPycBCD xeAfcEPU1Cz69WrmwRwVRvniTNUHroQM1IxSEJZr933ijzrfYChcHkESfmE5GDbg2szD Fv9LkRxIp+/czJByykReFpcXt21s6kBVh0qKAESGqcSEKTjKv260Mx9sTe7/AkRVvvsE X50cKRFlTV1lXaH8BAEpm+z5jq4jiMHC1CUvQZ59DDEuIcJTuKQgUrihstAEpHgyDTpa N8mQ== X-Gm-Message-State: ABUngvcnPj+1z/sX9UrkzlSAqUKcdFJUsY6Pfw1nRx0QaIybQBxXJkop9kqLEY6LWiOHhA== X-Received: by 10.28.96.4 with SMTP id u4mr18089435wmb.86.1478640962730; Tue, 08 Nov 2016 13:36:02 -0800 (PST) Received: from [192.168.2.21] (pD9E8FF48.dip0.t-ipconnect.de. [217.232.255.72]) by smtp.googlemail.com with ESMTPSA id 71sm3185374wmo.7.2016.11.08.13.36.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Nov 2016 13:36:02 -0800 (PST) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: FFmpeg development discussions and patches Message-ID: <6d200416-f02f-370b-3e15-c0bc58792bd1@googlemail.com> Date: Tue, 8 Nov 2016 22:36:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] dvbsubdec: fix division by zero in compute_default_clut X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Since the loop goes down to i = 0 the number of iterations (variable count) is the original i, not i - 1. In the case of i originally being 1, this miscalculation resulted in a division by zero. This problem was introduced in commit 4b90dcb8493552c17a811c8b1e6538dae4061f9d. Signed-off-by: Andreas Cadhalpun --- libavcodec/dvbsubdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index e9f4765..31898ea 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) list_inv[ i ] = bestv; } - count = i - 1; + count = i; 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));