From patchwork Tue Dec 13 07:16:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 1770 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp2071547vsa; Mon, 12 Dec 2016 23:17:28 -0800 (PST) X-Received: by 10.194.44.41 with SMTP id b9mr99317056wjm.56.1481613447958; Mon, 12 Dec 2016 23:17:27 -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 l90si1224017wmi.65.2016.12.12.23.17.27; Mon, 12 Dec 2016 23:17:27 -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=@gmail.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=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 815BF689F7A; Tue, 13 Dec 2016 09:17:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08D06689F37 for ; Tue, 13 Dec 2016 09:17:13 +0200 (EET) Received: by mail-pg0-f68.google.com with SMTP id p66so3595975pga.2 for ; Mon, 12 Dec 2016 23:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NbMDkYu83JZfwBvkgQ5zEh4E3n8+94ReebtkT1Ss+Jo=; b=PP8hwM9lJOw+S3kaXPz6gQkjnBNDCmpX1m8g/6mOkHPVl1UjjxKOGqyK5s7ivUTpl9 p3QIR4peyNQcBWfhd7XWkgu0hshM/+GpXhGF6CDMCaccOQ1fYRJsoIwRKu9Bo3Ym5OCM JL03mt9xgfPBizDmrl3ksGjGhgCSq+CNaA47ACCnhEmeK1HdW6WncG3m4xZANKYFfbPc 3OU4igBfnrd5nTuxBnR5EQDJLLb3OUcBR45BIu+MSGHBUVDsciHn0XBMVmgYTNUUNoCj hLpEzLYkcatZHpId3gZNZwAKqAyCA0EZLt2tH5JSqI9Lkikvv//6Q4b6Ch5r+kMIMZGh oYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NbMDkYu83JZfwBvkgQ5zEh4E3n8+94ReebtkT1Ss+Jo=; b=L4HqSKGA21BShV6CtG5zLxGwQSuC3DFN2x/bhKecHxaV73HE4MVyKQIy6E15KVf4bW +xW3dCbIyL1VxVNEJqNYcRY8eg68nabsdU45TBuFy86swU89fYcpxrxeHgrJdrTdixoT qNS6vC2T6Koe9dbG6KvDcnl8ZcUSDZzpDyVeIJfsjKEdTCcVchspzkAnGM/EvhsTIcSM cpwHm+D1B2tij3xFMZrL+7jFVIhM5fA6SIGkvbwjLdiJVRqqpG+vFYhHn253hqZhGSxM W/COq8Yg2V4YwNvS3qHddzGxM3V34HgFYKyvrrCf7tz3w/CkbXVR/n1j1rPv1f5PDW1H 6Gjw== X-Gm-Message-State: AKaTC01fHYLmke/Ytz4Z9YiTKXh71zFusSNUb5vyZ6vipKSwZFbv+ctrFRBrzIgP4dgR3g== X-Received: by 10.98.131.67 with SMTP id h64mr100284641pfe.86.1481613436681; Mon, 12 Dec 2016 23:17:16 -0800 (PST) Received: from localhost.localdomain.localdomain ([114.121.239.96]) by smtp.gmail.com with ESMTPSA id w17sm79625509pgm.18.2016.12.12.23.17.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 23:17:16 -0800 (PST) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Dec 2016 14:16:03 +0700 Message-Id: <1481613363-26810-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] swresample/resample: do not allow negative dst_size return value 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 Cc: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This should fix Ticket6012 Signed-off-by: Muhammad Faiz --- libswresample/resample.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index 71dffb9..ce6a82f 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -478,8 +478,9 @@ static int swri_resample(ResampleContext *c, int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr; - dst_size= FFMIN(dst_size, new_size); - c->dsp.resample_one(dst, src, dst_size, index2, incr); + dst_size = FFMAX(FFMIN(dst_size, new_size), 0); + if (dst_size > 0) + c->dsp.resample_one(dst, src, dst_size, index2, incr); index += dst_size * c->dst_incr_div; index += (frac + dst_size * (int64_t)c->dst_incr_mod) / c->src_incr; @@ -494,7 +495,7 @@ static int swri_resample(ResampleContext *c, int64_t delta_frac = (end_index - c->index) * c->src_incr - c->frac; int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr; - dst_size = FFMIN(dst_size, delta_n); + dst_size = FFMAX(FFMIN(dst_size, delta_n), 0); if (dst_size > 0) { /* resample_linear and resample_common should have same behavior * when frac and dst_incr_mod are zero */