From patchwork Wed Feb 24 10:03:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 25944 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 618A644B9E9 for ; Wed, 24 Feb 2021 12:04:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4318468A901; Wed, 24 Feb 2021 12:04:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB17668A646 for ; Wed, 24 Feb 2021 12:04:05 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 92418240692 for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QUwZnBKOKq9O for ; Wed, 24 Feb 2021 11:04:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6C14824068A for ; Wed, 24 Feb 2021 11:04:04 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2A6793A0135; Wed, 24 Feb 2021 11:04:04 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 11:03:59 +0100 Message-Id: <20210224100402.22300-2-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210224100402.22300-1-anton@khirnov.net> References: <20210224100402.22300-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] tests/api-flac-test: ensure the frame is writable before writing to it 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" The encoder may keep a reference to frames that were sent to it, so the caller cannot modify them without checking first. --- tests/api/api-flac-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 3fea3258f3..7c96a4d99e 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -154,6 +154,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, enc_pkt.data = NULL; enc_pkt.size = 0; + result = av_frame_make_writable(in_frame); + if (result < 0) + return result; + generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate, enc_ctx->channels, enc_ctx->frame_size); in_frame_bytes = in_frame->nb_samples * in_frame->channels * sizeof(uint16_t);