From patchwork Mon Mar 29 08:42:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26634 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 2B34844AD8A for ; Mon, 29 Mar 2021 11:42:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 187ED687ED3; Mon, 29 Mar 2021 11:42:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072019.outbound.protection.outlook.com [40.92.72.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14640680856 for ; Mon, 29 Mar 2021 11:42:41 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lawAvUXQWXp4uKqhNa1Cv+/9DT5O8UMwl7mzhXxwiNCruh+osQwNbXou3KoNtOGskrg9lTq6te9B2fbOScz+ZgSPFN3CeXFuSVUeGMyXp8ACSEHenKPa0zdfWNHp7Ir8A4oWbeSVx5mjNJbR7Ih9dLnC0CKn6kQusmaF3RzXmzbnD328OYDdK3jyz4TnHlOnqgWZw1fzF2ym9wXbil5tlPIgEVo1lGU2IDEVW435IRR9ls6FUeWBh6mryBufDqlJ7gsT2Ycj7p9ja9cY05XJ3RHkJWrO2krM+L4wsYoNG48bm/wX0Z8UaMJN1YFM/ZDklBFuGRI2gpiSq/dXzx0vqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q0cbs/5Ds7xnhhsOYTmXGCQDgjdAKr7l65zkMcuLwXs=; b=P3iWsWR4YN5yHFdn0BJgpXQklS3QkILK5AfpDfLNcPcPwMw+lJ7EBiguSAm3AwaA5Z4l/Roc0VU2GQe32QAIxExQzwcvphUZhC6ixv5EGti76ZDMT5vld8hW7yhfiOzNgdqdP6L/kB4jX7X5b7zwqiLFeHZgU6eFQ5jqoSBSPuhGydo2lJp573XKYCFowjTvWG8nxnia1A+HdTHZ5OrNDGwB3TWSoz4pO5VbA27rw9EzUUqo3Qwv+6lMm+2/NdcrHXNjsVeZClwuZpPIvHlaPtiPwBq/Y+LCaIZ+XVowIOuHa86ZCrh+1kOfjTPqn4V7FXeoJr4NmV6k9/+t9WFV4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q0cbs/5Ds7xnhhsOYTmXGCQDgjdAKr7l65zkMcuLwXs=; b=gHs0K9arGTMcAmxLEcK2/cRhb3qYQ3lwrKI8Qo64kQUv/42vZvS3i2ZVqMxNeAHhX4HPYdbxgDSs3jEcsWn96RTAd0oUrMAPPdaeIefqedJ5yRpZoR+o6LmbatJzcga0JB6IwN0dwm8rPECI06ldD1Qv0coxyqkarW6YWqlfMdTYkMRDfbma3KDA8YHc87Z//n7Qmx3AaNNo+zj5U92r6HVX9kvtLEag0Ew9jt7M8SAiHiLey7q3PMUccuZpSVWEn0JN6BjXXBb/aBwLG65w56D4rAoyn8X+L79jCFeZmvEAMm3PduQb/UgBJ5Q8IMh3Jg8V7Q2GOSGdtt5X3jfPww== Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::4d) by VE1EUR03HT210.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::501) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Mon, 29 Mar 2021 08:42:40 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e09::49) by VE1EUR03FT009.mail.protection.outlook.com (2a01:111:e400:7e09::92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Mon, 29 Mar 2021 08:42:40 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B2BE1164976668DF08F18CBAFCB715F638DF3E182F5C6431084C51C4FBE399AA; UpperCasedChecksum:D0BB135E486C72B406CC0A7F80D48691847F6CF19ECC552CAF8728A90E7570FE; SizeAsReceived:7550; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21%3]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 08:42:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Mar 2021 10:42:02 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210329084203.402250-1-andreas.rheinhardt@outlook.com> References: <20210329084203.402250-1-andreas.rheinhardt@outlook.com> X-TMN: [DGjMc1gFpy0gnN2QAZw4cv0CONtcwwZf] X-ClientProxiedBy: AM4PR0302CA0023.eurprd03.prod.outlook.com (2603:10a6:205:2::36) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210329084203.402250-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.137.96) by AM4PR0302CA0023.eurprd03.prod.outlook.com (2603:10a6:205:2::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Mon, 29 Mar 2021 08:42:39 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 7517c3c1-0bc8-4981-4021-08d8f28e9c7d X-MS-Exchange-SLBlob-MailProps: mBRmoEB1kyJI6Ri+2w4enS83RnwDVX5nnwKtGTcU8PYCTbNoJ0hpflOqHrF12JaJ9EV5bclrHVEgi/ZLH20HETIM1hSPktjlSmSApwF4wA81Q4eoBsMP/W0caLrqg77+UqqNF7nt0hG2ei4lHFC697lKCCu22c/uRpfKUUdFZLkVvXXMJsrKxWBXrbQCgttgCppDGqga+UYFjOUIx4dFDCMjmtdCT20FVeu9wQZOkfV0Xaueyn+mLfyvrfeFIJC3DeeteIWh3DFVVlhy+RxcXlFl9RxD4JfrzHc4fNcGQ+lsVwnifkJ6qJo8MQnj5IJ7Dz3kyfnnMoT92sdzRekFflGBZcq9pSfyniVXnyIFoDElVaRDXZGP6eu+pVB64X6ICcJP4POGQOXsk2chnm/VgjMRiuWGZwTIuwfFgE53wp0jXvum4nxbcXVxOoswrAJj11wBBSZ6fonponZy0G31TwIcvOjxDt1UALUyCuu1QPpSCQDCrIkt6VzA9ae/m2sWZvVgLJwIK1se91JtICgVo8GVz27f1KpGx+NIWMEbuQn21XPbtwsS0+8MZK+/2T2wPt5WAAJoOYqe4VG9hXx+Or7ZSyv/mmER/BMCcuR1Uoh7YRAIf10ZKa3T1q1ucshvpfHzysQHWEUIjnJwMF2fwbbuNa0PRER5wFfVDnf7QZUXMkZvvJGMMPIlC5oP9i3jUDGPmGd6FeQNlUzHDWxIilPOzSdHWdGRWH7GIA72BnjRFeE/4kfOirNkpM0uphxxVPpmf8z2/pE= X-MS-TrafficTypeDiagnostic: VE1EUR03HT210: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: on2jBA2UyOgJoq0blHOjlN9iZe7zbE7/QfDWeX9w9pDPC/S4VjlPhXLVhVptCpBM7bIC40QpXtzkbR4AzaqPdbjII1IX3NaH6ZMiyn2AoTfJcmMH1iOCWi4QhMPGmhZ3mlQ8E4ad47SpGZB1veCztAWQGo2DBrkuTDU2FEhR/SmN7Hs0VBkJewCUaIc3YBMdUglOxle/dinmgWcTB7dwJQOxuFGZUs1I/7dOsZrT1ef0npXl0UpZx0uMgiQexSLP5h69dds8fYpH/LLMQkB6+LG6T+NuFIuS3cOkgt7pBp5ciZI4bhcIQDwzX/QhdVPsIUHHW3UlInuEDuAVzezPwYiucPG5iXz4xw45X4SZ/wkSYJfx8Gz7a5E/6LVVa/YJvSfo3G3c3u/VbMQdyFbkzg== X-MS-Exchange-AntiSpam-MessageData: DEFyjRRUu7j7u/lNsH53tnWvELUdD28qVdojy6JM7CC+oFimwGVVgX7/prk7U5Jd9kKAgxvBjY8FkBuVnh/oL6hZ7Woi5lHUHm7Is36wucejKvfAnU7b+ndyZFndJZvDqQHE5lJF/o5ktnZwCQjIWg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7517c3c1-0bc8-4981-4021-08d8f28e9c7d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2021 08:42:40.0805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT210 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/utils: Free new streams in ff_add_attached_pic on error 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- mov chapter tracks are not compatible with this. libavformat/internal.h | 3 +++ libavformat/utils.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index b3c5d8a1d5..a6987619f7 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -678,6 +678,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt); * @param buf if set, it contains the data and size information to be used * for the attached pic; if unset, data is read from pb. * @param size the size of the data to read if buf is unset. + * + * @return 0 on success, < 0 on error. On error, this function removes + * the stream it has added (if any). */ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, AVBufferRef **buf, int size); diff --git a/libavformat/utils.c b/libavformat/utils.c index 2bd7dd8ec7..67302907b8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -474,9 +474,10 @@ int avformat_queue_attached_pictures(AVFormatContext *s) return 0; } -int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, +int ff_add_attached_pic(AVFormatContext *s, AVStream *st0, AVIOContext *pb, AVBufferRef **buf, int size) { + AVStream *st = st0; AVPacket *pkt; int ret; @@ -493,7 +494,7 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, } else { ret = av_get_packet(pb, pkt, size); if (ret < 0) - return ret; + goto fail; } st->disposition |= AV_DISPOSITION_ATTACHED_PIC; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; @@ -502,6 +503,10 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, pkt->flags |= AV_PKT_FLAG_KEY; return 0; +fail: + if (!st0) + ff_free_stream(s, st); + return ret; } static int update_stream_avctx(AVFormatContext *s)