From patchwork Tue Nov 30 00:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31822 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp6968542iob; Mon, 29 Nov 2021 16:50:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcSWpMFQVc45dQ6DciqnT1WqqK8H3xBfZqoBpCbMVnsypQcd+BtdrxKuAwjSlTuda6O/iX X-Received: by 2002:a05:6402:2792:: with SMTP id b18mr78475506ede.329.1638233422504; Mon, 29 Nov 2021 16:50:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638233422; cv=none; d=google.com; s=arc-20160816; b=TGIn4FNmN2ELBp74EeUkJowRq4YAglw2emjAIaCI5+IDFCYUAQQHFSLG+n8rvXt/FM 60Ymyhpdle8dfB1RySDGSCEip3XTHn0ZDmvTAt/ufed2OwYvJhjKhbU22Te1RkHACd8o ibk4LxY31tVB+XvGj+o1MeT7r5JNZ9T6sGwTn/0vRW9nQUafmFTSmbNPJzJ2nhXo54vV H68J2JnkFfqUzULIvTXFchX0qc9ITdVCQrKrodqKryuqtdHO44odeWyOqHsPX+OjHd88 Ale5KJpOzCuE3NkZ7G/fEAveTVPgQ8zxmL2skrPEzH2r9afjYCkAWkqdKYuLllNTJAvx JR6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=IG6U/8fvbIdyfJb5EF4+pCn1j0wJzxRx2T80hZ87PWc=; b=BYVWWMWDbfNRu2Z2M/wRTZF1KbW31P/m1TmiJRH28fDSAqVM7Ag/AqAyv0b3JmJ8og auc9W+o1mW7P1QDNs2fQNUAzGQ7trY8WupMw4soqZ4EVPOKaO4TDsK3tMbJs531yainB INeYCt7wrv9O9v4CpPjFi2qRTQpjoMEwqlverzRqkRy1S+8M7DaUWrPU5CS4YHLT8MlV qBCxMTt7S2gLGJZGxHVOdh1YD+gEfoAVXeDzIEc1BPszba/uWfAKYk8WwXr4sA09Ph2P 8vnkeVDEpx+6Bad0q8tfx9iBnsG+iGZOalUopjpNoLVZe+P9gtiRdgaST9R1leGbG4NC Snww== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r24si20297897ejy.718.2021.11.29.16.50.22; Mon, 29 Nov 2021 16:50:22 -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; 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 1211068A868; Tue, 30 Nov 2021 02:50:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4739A68A868 for ; Tue, 30 Nov 2021 02:49:59 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B71E9E3E38; Tue, 30 Nov 2021 01:49:58 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wk0aDwkoT7j8; Tue, 30 Nov 2021 01:49:57 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 84C60E6372; Tue, 30 Nov 2021 01:49:57 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 01:49:47 +0100 Message-Id: <20211130004950.30697-2-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211130004950.30697-1-cus@passwd.hu> References: <20211130004950.30697-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avformat/aviobuf: return stored AVIO context error on avio_close X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MfcQw4PfIZWQ Otherwise IO errors at avio_flush() before closing may be lost. Signed-off-by: Marton Balint --- libavformat/aviobuf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 5da4dea7b6..d65c7b535d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1231,6 +1231,7 @@ int avio_close(AVIOContext *s) { FFIOContext *const ctx = ffiocontext(s); URLContext *h; + int ret, error; if (!s) return 0; @@ -1249,9 +1250,14 @@ int avio_close(AVIOContext *s) ctx->bytes_read, ctx->seek_count); av_opt_free(s); + error = s->error; avio_context_free(&s); - return ffurl_close(h); + ret = ffurl_close(h); + if (ret < 0) + return ret; + + return error; } int avio_closep(AVIOContext **s)