From patchwork Sun Nov 12 13:01:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 6009 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1052305jah; Sun, 12 Nov 2017 05:02:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMZkg/cxDIppGori/LC5dzYMwUO7lFvrOlzQ6Af2eIgV3TdchyHq7ZQq5zE00eWY6bbsC678 X-Received: by 10.223.141.129 with SMTP id o1mr4768745wrb.95.1510491730553; Sun, 12 Nov 2017 05:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510491730; cv=none; d=google.com; s=arc-20160816; b=vKRCuGrVRLWzxKqmdPUN2Dy2ndbGr6kdSxKgrcWI8hwFPYenYNA0YJLZb0WS9Vi/k9 A922mAxolAgJ4h4XJ6K2ZJzCfz2cIcWl8krMvj5xWsJ61Bwf9uOoSN75yciiRntF3cOa Mo4RJen+Ic6X9iNmCQicviyBxQHzOOE8U9cpVCVi8eVNF8gxsI6UlP4alMf2C5sPNXyW Q2/nFjCHRhhZiHZOkRCkSzh4B3NhMp4FQXTr4rfB8UkeWwxSMScpuovg16w8dDNXdYH4 w7BRvDaunQBdUmeFYAnwR01xp2Am+kghQ+inrorvxFwQB/bmSvhpWDOd//lmOkiNmDgg d0Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=q9/czr2BsXCDKmL/6RKyIe5OMwQBKQyZDrmLgAAte7s=; b=pfp90I4oEmXVZrjks48sSIjfsZtfq7kU4b98YUer4nmwMfFxwR+Qvp0A/UvZlevGz1 V9HqopS+K9DCQYXwA/Q+JuC1noDbevm42j1GmQgtQKam3182pgxO+DwCfzYbTIVhWmgN 3uzSCnZnPqyegWzk90dBTn86A5hu/dFoM7BlIMNy4u0lXsYoL9oGYBvLkvjeEbDp89HJ ke8RsJYjAcOmDAxMs2E91J9DTTxuPqtFrORhrtAPpQ9KTntjqnpfSgZfA0vlfvFIfI1a n5eU1Ba6c8IRbENRv9+tCGxc20Ht745AELHcdgxkhSf1x/f/DIuIHO/0Z+PcWelCPZDw 723w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=qM0Jn0eD; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s127si4247948wmf.150.2017.11.12.05.02.09; Sun, 12 Nov 2017 05:02:10 -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=@rothenpieler.org header.s=mail header.b=qM0Jn0eD; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6C4E68A3DF; Sun, 12 Nov 2017 15:01:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 952AA68A329 for ; Sun, 12 Nov 2017 15:01:48 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8109:43f:959c:ba97:5aff:fe10:ec69]) by btbn.de (Postfix) with ESMTPSA id 862CB63C17; Sun, 12 Nov 2017 14:02:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1510491722; bh=ClFDgK+KqLAlw/C/eWFE5ZHKi3XmmY+WfjMgc9GGC+0=; h=From:To:Cc:Subject:Date; b=qM0Jn0eDwcAFe2x1RBhpsXp6e3U/OPKN562XXdKbDDgcEK/nWOlg8nIveVbA6Tgmm CctPEk0V/ZLs1ZwP2IV92avSGUrtm9mVT2RdP8B5T+9JV90jbnRBlIEWqilm6rvAF7 XeHQU65sFeLvVuiZjgKwKt2zGHe43zR+DS0AyviI= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2017 14:01:51 +0100 Message-Id: <20171112130151.7841-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH] avcodec/decode: don't increase hw frame size 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: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In case the hw frames context does not return way too large frames, but slightly smaller ones(for example height being 1080, while coded_height is 1088), this causes failures because various code will try to read/write beyond the frame size. --- libavcodec/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index a7f1e23fc2..0a5ec6a21b 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1491,8 +1491,8 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags if (avctx->hw_frames_ctx) { ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); - frame->width = avctx->coded_width; - frame->height = avctx->coded_height; + frame->width = FFMIN(avctx->coded_width, frame->width); + frame->height = FFMIN(avctx->coded_height, frame->height); return ret; }