From patchwork Sun Mar 22 03:47:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18318 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 D349C44BCD9 for ; Sun, 22 Mar 2020 05:48:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AFFA168AF7F; Sun, 22 Mar 2020 05:48:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A916268A82D for ; Sun, 22 Mar 2020 05:48:09 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id 31so6282343wrs.3 for ; Sat, 21 Mar 2020 20:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HbxMhMgIgQ0g4GBPeWtL8Jmav598XJumLzBdqy9bdQ8=; b=JgBiCU3Va7yDab5YXPDhnfrwO/caUEL3lnQoIHgdWOEY8Uhw2McptFDGkC7aDkywy0 WjCpgvHDTJtxYTnVVQn+zQp/QfVCGwT8D8Spzm2HcbGoqvn2EleKtXD6ql940A29phsf /eiemdQVpjg9n99+ndR521zqVE/ioNxHhziuh+h9Ak2I9QBVKR4UgCQDhrwc/Reva4Y0 V8JDhilRQFt6XJiNpfCRRDv5fYmVBU9cx4a4mQDCQdMefmzWl5Xb9AJ4yUN/UKy9zlLW CP+26lftctrPJ1fhJHObU6ND7VUKU1YIFT2vErAnmqq8uUSrNwX6gwPwaQI40f5lGf4i c+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HbxMhMgIgQ0g4GBPeWtL8Jmav598XJumLzBdqy9bdQ8=; b=rHhmrojddtsuu5M+axNDKtnnJJKpoiygF1miLnhCD7njRiS35+QuLZ52QM01Xy+Jqf rJI8uQztjkjTblw2E5jwq4kFaqiqHlkkSmUM6D34oDK10hBP8tVchZrz79caMpBvkjhX ojAe9TBQO8UMjCgcVGhr1xMyNDE15iKY2Y3siadoPAr7BQdWqeaawWtaoI/6aOpQ+eKj /cuqit34b83knAqNGOthjN/X00Vu91wPmdifEzGLuiVgwmurTU55JHwCkz8BHMrN5oxv zxbx8RyEazaxMw8rFWftCeNQ4v7/jvWLM49ZPaZJpPYZoNzjFSf63jcmNnCFzMCcyAsm GgNQ== X-Gm-Message-State: ANhLgQ3mv0I/o2t9GQbT4fVjcgmWzsIENZDCl6774aaGrd1mLJCSMslv sQTX/cMy/FeR5GCpcoyJqcND3VB7 X-Google-Smtp-Source: ADFU+vuyp+l6rF6XRmZk+T2A4tWPvurwVW+2bXKbaeAYIw+0Zf1je6tyIY70J25lgyYI3ip0BwMwkA== X-Received: by 2002:a5d:440a:: with SMTP id z10mr21262119wrq.177.1584848888513; Sat, 21 Mar 2020 20:48:08 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:36 +0100 Message-Id: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/21] avformat/nsvdec: Use av_packet_move_ref() for packet ownership transfer 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" Also simply return 0 in case a packet has been successfully read. Signed-off-by: Andreas Rheinhardt --- libavformat/nsvdec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index b5d9313778..eb26b29450 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -662,10 +662,8 @@ static int nsv_read_packet(AVFormatContext *s, AVPacket *pkt) /* now pick one of the plates */ for (i = 0; i < 2; i++) { if (nsv->ahead[i].data) { - /* avoid the cost of new_packet + memcpy(->data) */ - memcpy(pkt, &nsv->ahead[i], sizeof(AVPacket)); - nsv->ahead[i].data = NULL; /* we ate that one */ - return pkt->size; + av_packet_move_ref(pkt, &nsv->ahead[i]); + return 0; } } From patchwork Sun Mar 22 03:47:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18319 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 0197B44BCD9 for ; Sun, 22 Mar 2020 05:48:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D90B068B405; Sun, 22 Mar 2020 05:48:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D5C768B3AF for ; Sun, 22 Mar 2020 05:48:27 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id h6so12272068wrs.6 for ; Sat, 21 Mar 2020 20:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LaF5pa1panXnGMzp/4oDSWLPXH4Gr5bhVUZDV9LPiYw=; b=IPwBc5WZphjhqi5Z3aJvpf+SXNggtFogI1+3wF45cnLOi+7n9v9MccJWBAcwiPzuvo W+aaECrpGHs8q33JdR6/P9JcHenqujviichvt37JlRQNPM6ku7o59a/rTyQujE0mkGI9 PtzdWqrTGP3xEZFpjXNBdBas8zgpopubvIC4zqIfchhiGRrR4Gf3QWdmsSfCQHk+xZO5 0fWAfqYe4X82DNwu8QjYZ5yiaCKT3RWQFqJEAOwJpMNZLsEFAbR+6Ngf66TDoWSEPvLv 437abdy6d/uWINlWkyHNg27KBta4CXe8W7MVATG4++2bEkzDdVQu6HtUUpwGrYKeXs6Z wcyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LaF5pa1panXnGMzp/4oDSWLPXH4Gr5bhVUZDV9LPiYw=; b=phkQvJ9YHbnosUjRjfNQvHYzY7uz/lhx8VB9BX/YNIiZi0U2K1FBFsqDAOBvcGRm3y jplDe2NMB7Py3mgBlzk7kb/RRj4NPEXePQlBI1ZO/0w7mw52ws7SQIVSRzR6N5dI68Wz mZea7+LdKrGxegOgZuFF8MgJkxVeSFt3HQ9G0AMHh/6OGdLWnFoYr3GXHieg0EXJLYdm STGHblZce2NHIQRFDvyTB4E7jY6z85d+/u3vWVEHS2WY2Fcy81DJVtLh/AUrt0QFGMyX xt5LfuDJbL+qRhCCkVlkkVrCizgf5CE2/ySC6QLhr4DsABsIZoTonvDE0F9D3Mw30Qdl 56ig== X-Gm-Message-State: ANhLgQ0pygUQY2N4FXa2WEhpihO0ULYc8J7kNxx2GjQh5aRfP67QD4iP PL+W9IsHyAB70ZjxURGwz4N+mRFw X-Google-Smtp-Source: ADFU+vtzeVaiZKjRv+itXOKRgZT11gJpRQQ4YYekarmvXyK3YRRn0TtPjsbR10Xunj3ti61PcQ42AA== X-Received: by 2002:a5d:6182:: with SMTP id j2mr3086678wru.131.1584848906251; Sat, 21 Mar 2020 20:48:26 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:25 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:37 +0100 Message-Id: <20200322034756.29907-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/21] avformat/yop: Use av_packet_move_ref() for packet ownership transfer 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" Also return 0 after successfully reading a packet. Signed-off-by: Andreas Rheinhardt --- libavformat/yop.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/yop.c b/libavformat/yop.c index f9ead026a2..0d8d9f2ff7 100644 --- a/libavformat/yop.c +++ b/libavformat/yop.c @@ -125,14 +125,11 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) yop->video_packet.stream_index = 1; if (yop->video_packet.data) { - *pkt = yop->video_packet; - yop->video_packet.data = NULL; - yop->video_packet.buf = NULL; - yop->video_packet.size = 0; + av_packet_move_ref(pkt, &yop->video_packet); pkt->data[0] = yop->odd_frame; pkt->flags |= AV_PKT_FLAG_KEY; yop->odd_frame ^= 1; - return pkt->size; + return 0; } ret = av_new_packet(&yop->video_packet, yop->frame_size - yop->audio_block_length); @@ -166,7 +163,7 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) av_shrink_packet(&yop->video_packet, yop->palette_size + ret); // Arbitrarily return the audio data first - return yop->audio_block_length; + return 0; err_out: av_packet_unref(&yop->video_packet); From patchwork Sun Mar 22 03:47:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18320 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 08E8A44BCD9 for ; Sun, 22 Mar 2020 05:48:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E582F68B479; Sun, 22 Mar 2020 05:48:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1E2DA68B370 for ; Sun, 22 Mar 2020 05:48:29 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id b2so12265451wrj.10 for ; Sat, 21 Mar 2020 20:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QYTGd0sieNKm3BUB6bPmyWu6r1Zz839doYRWHo41ZtA=; b=OOybiafQKwO8F2zLf/hwMuUu8BflaW3EiJ+MJUi4vp5h0QtiBgilFAeCeEhFNpdQec pqFQ49oV76+pgbY29hCqG5jcgCQG2o7bFI7LLDpKJB5uNKdQRQKihRUbdVv6m8iAH8AM sq9O1AFAZO1EwmZmqOoJWA21K/qya3HQo0zQIeuPZxHlsVSvugpm+K9evv3xnX1J5sK/ 9GzuOEi7qTkz3U1FcL4K5t3eCogI1k7Psv7v4Y7Ejw1l/vefcf30SQZVjEI426h9sQBu Zoz3FPMgxYdKFiEvocHNuopYE8+FxoMKGckMdM3nhYgprGL9ItcxIiPuSUFN9uHKItCZ +yeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QYTGd0sieNKm3BUB6bPmyWu6r1Zz839doYRWHo41ZtA=; b=gPsME1jdWZkuXytMN5b6pD9uDoNPCfuFBXxhNYAJil/+sai6kkv6413vdp7dM0PVMa gD6L7eGA7oJpE2Ezc00LhKctgMAUTWShRupY/XUi/Kp6veGlTNCpkBzGWsdS4T7LenDN 7Cil1QVInvohUz3PNiHAUBfI/SktqGaVcfKnZTpzUbTXRJ9R350w2o58oViR41kbULh/ Gp9+uBES1Q2PuqvG5B/AOQYS03MdyEeP2tSQi4jTPdL9M0y6cNQ0mx1bEYbP9ghwj+A1 HyI89NHuYIzSLOKOpgBzaovK864MrFvPbeTCJWiOH16+0QjvWLV6zvVR48NPMz4M3Q8j /m1A== X-Gm-Message-State: ANhLgQ141aA5Ip91Yifywi5iOypeiuQpfiIDFFhwd3+eL70uiUrJK3yK MVGl1yOtbImXHxpUOeBUiPVok9uI X-Google-Smtp-Source: ADFU+vtt9zHyTv1QB8iKyQ3S2GpH8DjRy21DbYqvRw5EzLl8VM5UqEVtUrY2RwfaD8wAuqA7Ae9KHg== X-Received: by 2002:adf:d0cf:: with SMTP id z15mr21874681wrh.357.1584848907326; Sat, 21 Mar 2020 20:48:27 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:38 +0100 Message-Id: <20200322034756.29907-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/21] avformat/mpeg: Remove unnecessary av_packet_unref() 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" Forgotten in 6a67d518. Signed-off-by: Andreas Rheinhardt --- libavformat/mpeg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index fad7c7fd55..eba5852266 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -961,7 +961,7 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) if (ret < 0) { if (pkt->size) // raise packet even if incomplete break; - goto fail; + return ret; } to_read = ret & 0xffff; new_pos = avio_tell(pb); @@ -978,7 +978,7 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) ret = av_grow_packet(pkt, to_read); if (ret < 0) - goto fail; + return ret; n = avio_read(pb, pkt->data + (pkt->size - to_read), to_read); if (n < to_read) @@ -986,10 +986,6 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) } while (total_read < psize); return 0; - -fail: - av_packet_unref(pkt); - return ret; } static int vobsub_read_seek(AVFormatContext *s, int stream_index, From patchwork Sun Mar 22 03:47:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18321 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 DADF944BCD9 for ; Sun, 22 Mar 2020 05:48:37 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C173768B4AB; Sun, 22 Mar 2020 05:48:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4A3368B3CB for ; Sun, 22 Mar 2020 05:48:30 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id 26so6207064wmk.1 for ; Sat, 21 Mar 2020 20:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0kSCVTN7xTbUIdvvswS2+ishV7DtdsoHk2UMJUa6uFU=; b=pnnB2Swr5KPSPuuZniNbTGrWALoTOEra2MkU/zVjsM/5lQMpd/Gyxh8onZi8ygATll WngQAxRNgH04ne3eqQrwvMnNx9mac/6CMzNVYzHt2ynoyrG9w/gnrOFYblzhAbDGRCvf ONZJtBXFhTvl/OYA+xxDWOpb2Eyi54+qGQ67QeuhQT0T9FD/905X0TbMztt3OOLDe7uS pXKylTyfNafHTzwbl0sdYkgLyM9BpACsf3ASrC/wpVSmWRewAor1z4tqKg57HMKpjJLr WazdTudFDu6FSHEyNWoPp8LbCZNdPBzRVQfqXsTPo0pLmLkKsdzwHaDt21uFLLU+DgJd y4CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0kSCVTN7xTbUIdvvswS2+ishV7DtdsoHk2UMJUa6uFU=; b=fMgPnINjzEwVp32pVPvi/pxMpEEx+JCaScv4DqDkJUoCyD+7ScSzFiz/pnt6xpdrDL 0Sox0SGpcXSOn/zxIlA5K9G0PxIbdgi98HRlxlNgG2lR8/h+oqtgc200cqBRKWCMCgXj 1BmaykTGxSOnT/jMQ0nb+cz3iUJ+MqnaxXg21C1fb779k4Vi3wVi7B1t+sdTJXlflaMq J1Vcq6ClRhT/RSa5nfPi6+ixLflYBSlrkriskq9nLc4d+i2z/mrFVvuLijgsFHSMMQIU 1/2iGR1o0sscxm+xnI7ViJ5WeV7A6UWJOj6ERxcpF496RUZ2ZUbINLn162jDqi+SrUgZ pgFA== X-Gm-Message-State: ANhLgQ1OL7X13QaWVLNO5rpt/pp4hW+2x2TJYbT+SCnLNkyKPQirvNJd FQ2e/igKqlsCQm8tAPuMmJ40ck6f X-Google-Smtp-Source: ADFU+vsrL7WwtyXyyS0PD58hRAPIQ88PHmKcOPsxxkAPG5fgjf8kbJcZsCdwtenQm77SFf1TMqg/PQ== X-Received: by 2002:a7b:cc96:: with SMTP id p22mr2906095wma.118.1584848909518; Sat, 21 Mar 2020 20:48:29 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:28 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:39 +0100 Message-Id: <20200322034756.29907-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/21] avformat: Redo cleanup of demuxer upon read_header() failure 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" If reading the header fails, the demuxer's read_close() function (if existing) is not called automatically; instead several demuxers call it via "goto fail" in read_header(). This commit intends to change this by adding a flag to AVInputFormat that can be used to set on a per-AVInputFormat basis whether read_close() should be called generically after an error during read_header(). The flag controlling this behaviour has been added because it might be unsafe to call read_close() generally (e.g. this might lead to read_close() being called twice and this might e.g. lead to double-frees if av_free() instead of av_freep() is used; or a size field has not been reset after freeing the elements (see the mov demuxer for an example of this)). Yet the intention is to check and fix all demuxers and make the flag redundant in the medium run. The flag has been added to a new internal field of AVInputFormat, flags_internal. When it has become redundant, it can be removed again at the next major version bump. Signed-off-by: Andreas Rheinhardt --- libavformat/avformat.h | 7 +++++++ libavformat/utils.c | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9b9b634ec3..50b90788b1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -780,6 +780,13 @@ typedef struct AVInputFormat { * @see avdevice_capabilities_free() for more details. */ int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); + +#define FF_INPUTFORMAT_HEADER_CLEANUP 0x0001 /**< read_close() should be called + on read_header() failure */ + /** + * Can use flags: FF_INPUTFORMAT_HEADER_CLEANUP + */ + int flags_internal; } AVInputFormat; /** * @} diff --git a/libavformat/utils.c b/libavformat/utils.c index a58e47fabc..87807a7841 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -400,8 +400,12 @@ int av_demuxer_open(AVFormatContext *ic) { if (ic->iformat->read_header) { err = ic->iformat->read_header(ic); - if (err < 0) + if (err < 0) { + if (ic->iformat->read_close && + ic->iformat->flags_internal & FF_INPUTFORMAT_HEADER_CLEANUP) + ic->iformat->read_close(ic); return err; + } } if (ic->pb && !ic->internal->data_offset) @@ -628,8 +632,11 @@ FF_ENABLE_DEPRECATION_WARNINGS if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header) - if ((ret = s->iformat->read_header(s)) < 0) + if ((ret = s->iformat->read_header(s)) < 0) { + if (s->iformat->flags_internal & FF_INPUTFORMAT_HEADER_CLEANUP) + goto close; goto fail; + } if (!s->metadata) { s->metadata = s->internal->id3v2_meta; From patchwork Sun Mar 22 03:47:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18322 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 3DB8244BCD9 for ; Sun, 22 Mar 2020 05:48:39 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1977668B4C0; Sun, 22 Mar 2020 05:48:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8177768B497 for ; Sun, 22 Mar 2020 05:48:31 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id a9so7595305wmj.4 for ; Sat, 21 Mar 2020 20:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=98yLOsYqPoxCC0FCly7IF3Dutm0dA6gBrPe2P9TC5wM=; b=mpI59y+7rSxRZVqPoK0RfVNfgiM5COc1Q2SqA7PPn5ojjYg4/UsO8Qu8oe5EibiN88 trzFJaArtdh1dSItMj4W0Dpcd9c88eKi6sE3Li44I8W+GGf0+DPaQMU3vt4tu1ry9ZPy pt3sPWyAosZ6CCmZEEsgT0lovx4gkc342LVQDi1Rg4nmnOdaNOB1WKVCjvYbilDDOd2l ufYbD48Uu+yF2UcuzeevTVtX6Tt8TOHUcIEgEe9jXNEbFgd/yMIKBKr4IF37DmQitn7z vLxXG+nIMAl7HJhuGEqGKEdDPgkLeGKOFOnwFgkFqAG7/Leh+2go1Th//gvM4HWGRD4+ iySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=98yLOsYqPoxCC0FCly7IF3Dutm0dA6gBrPe2P9TC5wM=; b=fxcU7pIEyPbdvF4siWHKsgZoQq5l0EwtJ56VJ6lN4ek3MreodAtVotcAe2tzsPyUMy xvD4bqFf/NLuO+o9jPxKj0T4H70FVh16eg5UIU3DN1pQ5iNhM1soPP0rOiRvCDE1Yv65 2kt0Xt0huovq4Q8Zg5VtoZcAVBMyFADQkDZORryWntNFgEYdL4Bc7pff+KKCyBe/Kv5m va3MYqvzOZICOZG4e/e+FaWx5R3cMov26iTmxOlpEmOjyFzFGs+8hQ0kr9EmftYP2j33 R1sn74ymCgvnRmtl9FoZSCEyxlhriaZfCvHc1gewDKIRPEk49EA5En4VvqJPCxxxlVIa 2ftg== X-Gm-Message-State: ANhLgQ01fUye/+e9vjR1zUlJHy4cx19a9IC12vo6Jdh6G+EbOSBK8Ufr S1IQ9F0UBTa2gbORxsxnck/tCCGQ X-Google-Smtp-Source: ADFU+vtAHHs4AQf+BGxOAlyGtCLb+zGJful/nXLb07oriU3UIkfZo1SQBFe4yrPqRfmmp4e90FMMPQ== X-Received: by 2002:a1c:9a43:: with SMTP id c64mr17983343wme.173.1584848910560; Sat, 21 Mar 2020 20:48:30 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:40 +0100 Message-Id: <20200322034756.29907-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/21] avformat/matroskadec: Fix memleaks on read_header failure 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" This commit simplifies cleanup after read_header failure: By setting the FF_INPUTFORMAT_HEADER_CLEANUP flag for both the ordinary Matroska demuxer as well as the WebM DASH Manifest demuxer one can remove the "goto fail" in matroska_read_header() as well as an explicit matroska_read_close() in webm_dash_manifest_read_header(); the forward declaration of matroska_read_close() can also be removed. For the Matroska demuxer this fixes a memleak when adding an attached picture fails; for the WebM DASH Manifest demuxer this fixes memleaks because calling matroska_read_close() has been forgotten on several error paths. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4d7fdab99f..31b0a73660 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -749,8 +749,6 @@ static EbmlSyntax matroska_cluster_enter[] = { static const char *const matroska_doctypes[] = { "matroska", "webm" }; -static int matroska_read_close(AVFormatContext *s); - /* * This function prepares the status for parsing of level 1 elements. */ @@ -2837,7 +2835,7 @@ static int matroska_read_header(AVFormatContext *s) while (res != 1) { res = matroska_resync(matroska, pos); if (res < 0) - goto fail; + return res; pos = avio_tell(matroska->ctx->pb); res = ebml_parse(matroska, matroska_segment, matroska); } @@ -2859,7 +2857,7 @@ static int matroska_read_header(AVFormatContext *s) res = matroska_parse_tracks(s); if (res < 0) - goto fail; + return res; attachments = attachments_list->elem; for (j = 0; j < attachments_list->nb_elem; j++) { @@ -2937,9 +2935,6 @@ static int matroska_read_header(AVFormatContext *s) matroska_convert_tags(s); return 0; -fail: - matroska_read_close(s); - return res; } /* @@ -4129,7 +4124,6 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) return -1; } if (!s->nb_streams) { - matroska_read_close(s); av_log(s, AV_LOG_ERROR, "No streams found\n"); return AVERROR_INVALIDDATA; } @@ -4200,7 +4194,8 @@ AVInputFormat ff_matroska_demuxer = { .read_packet = matroska_read_packet, .read_close = matroska_read_close, .read_seek = matroska_read_seek, - .mime_type = "audio/webm,audio/x-matroska,video/webm,video/x-matroska" + .mime_type = "audio/webm,audio/x-matroska,video/webm,video/x-matroska", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; AVInputFormat ff_webm_dash_manifest_demuxer = { @@ -4211,4 +4206,5 @@ AVInputFormat ff_webm_dash_manifest_demuxer = { .read_packet = webm_dash_manifest_read_packet, .read_close = matroska_read_close, .priv_class = &webm_dash_class, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18323 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 54CA244BCD9 for ; Sun, 22 Mar 2020 05:48:40 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C25268B4B5; Sun, 22 Mar 2020 05:48:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BA8D68B4A2 for ; Sun, 22 Mar 2020 05:48:32 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id r7so10430989wmg.0 for ; Sat, 21 Mar 2020 20:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eXFopYUoXsG+lolyvBBiE/fJxoWbx+YIeez7wgL8jcE=; b=ezP06L3LPbUZc8kRz1xbu9gDwy+5olazMZYcZHFJNZxY19x5Q27+8IliZ3OVc+y9hE 1cveaFKPh1VCCdDUxMvBDVx8ABdN1jOUXjB48mwpEapIrHTRguCRNNMYp3K1CA6XYj/1 Xoozoaat/+DLSm2OV3tfGEIl/r4OE8Ofv7yqZUtZP9atZiZESIfGu27z5lO00JIuMVX8 9JFy7SRHcspRbFs3kJ9Aj0j2AezJg8lSjKv3QWQXu8xKFyKo03athrPc/LyBcl8LmdPB qpoIyYqqa8wgmDfrrSSW51sVAWoW85cAro5/KyNAYGGPFX4ckWgmc1PSveV950+MDUPb +jtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eXFopYUoXsG+lolyvBBiE/fJxoWbx+YIeez7wgL8jcE=; b=eynFLhSjW8dpXri4Iq3PHC3wHRh4mwxuWV4rw0PMPYEpLwbqJVEw8DNmFl+AONfiVC zRzmRV8WOOfSbRKxge/5EEVFsQoJHzwNs3N4MXNeQYA3+m6CrTDFs+s9aicIqEI2nts0 Jdi76tNFId7iPrvCU9TapUf4EXX2eDdOhDRmWDp8oyrTdvLHdJOHQ0OMxzSP4tq7lOYQ ThmYCKjESSfsIOV5AvFsdEfj/7J8PvnepxnwPDVjbXx2/DAWhaSJM9AKI0aMXUHf4KOO doPXenhazyo4xYoYJv8iJlGSXGxbyIBcYIXJPk/qV4LFCC+wD4uMJuwu01YSO0twOK/S mcjA== X-Gm-Message-State: ANhLgQ2d2LB9y4+Wc7kp0oxZKocrbTBEmXMWNE5OA7IxibsSuX0BCxhq +EwlclGMMbFLdZ+ApG0z6ASqsajo X-Google-Smtp-Source: ADFU+vvMTnks9XgME4YZLeG/QN93j5U74p+1rMdg79MBt4/fdna9d3C9DkuSeleXMOlYrhwPCpUtWg== X-Received: by 2002:a1c:5fc5:: with SMTP id t188mr19503431wmb.110.1584848911642; Sat, 21 Mar 2020 20:48:31 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:30 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:41 +0100 Message-Id: <20200322034756.29907-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/21] avformat/mov: Fix memleaks when adding stream side-data fails 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" By default, a demuxer's read_close function is not called automatically if an error happens when reading the header; instead it is up to the demuxer to clean up after itself in this case. The mov demuxer did this by calling its read_close function when it encountered some errors when reading the header. Yet for other errors (namely adding side-data to streams) this has been forgotten, so that all the internal structures of the demuxer leak. This commit fixes this by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag so that mov_read_close() is automatically called when an error happens when reading the header. (Btw: mov_read_close() is not idempotent: Calling it twice is dangerouos, because MOVContext.frag_index.item will be av_freep'ed, yet MOVContext.frag_index.nb_items won't be reset. So the calls to mov_read_close() have to be removed before the switch to freeing generically.) Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f280f360b6..61fdb45d9a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7494,13 +7494,11 @@ static int mov_read_header(AVFormatContext *s) avio_seek(pb, 0, SEEK_SET); if ((err = mov_read_default(mov, pb, atom)) < 0) { av_log(s, AV_LOG_ERROR, "error reading header\n"); - mov_read_close(s); return err; } } while ((pb->seekable & AVIO_SEEKABLE_NORMAL) && !mov->found_moov && !mov->moov_retry++); if (!mov->found_moov) { av_log(s, AV_LOG_ERROR, "moov atom not found\n"); - mov_read_close(s); return AVERROR_INVALIDDATA; } av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); @@ -7574,7 +7572,6 @@ static int mov_read_header(AVFormatContext *s) if (sc->data_size > INT64_MAX / sc->time_scale / 8) { av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n", sc->data_size, sc->time_scale); - mov_read_close(s); return AVERROR_INVALIDDATA; } st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration; @@ -7590,7 +7587,6 @@ static int mov_read_header(AVFormatContext *s) if (sc->data_size > INT64_MAX / sc->time_scale / 8) { av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n", sc->data_size, sc->time_scale); - mov_read_close(s); return AVERROR_INVALIDDATA; } st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / @@ -7614,10 +7610,8 @@ static int mov_read_header(AVFormatContext *s) switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: err = ff_replaygain_export(st, s->metadata); - if (err < 0) { - mov_read_close(s); + if (err < 0) return err; - } break; case AVMEDIA_TYPE_VIDEO: if (sc->display_matrix) { @@ -8098,4 +8092,5 @@ AVInputFormat ff_mov_demuxer = { .read_close = mov_read_close, .read_seek = mov_read_seek, .flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18325 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 435E644BCD9 for ; Sun, 22 Mar 2020 05:48:42 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3431468B530; Sun, 22 Mar 2020 05:48:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 930EA68B4B3 for ; Sun, 22 Mar 2020 05:48:33 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id 31so6282666wrs.3 for ; Sat, 21 Mar 2020 20:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c3uCayXtJzh6uNYCPcqlb3Y3lknaXvEwaqQDHs38NMM=; b=AQYLh8L6RsgXCivrcsLujlpcO8DiUCi9iIxeAHfK2gTHt4dt5iNwEv5dBk3ogKjyH7 loOoa2TdiWGfB1el0tP+tzWZ1r1HdhGD/ixuSDwjyl5KT/lSy5jCjROad2wS42b0/K+o lPtnfsSYXRP5RfZy0PSuRvfyJTOSxMLRohdLWjvgDoNITp5GFVSGWgZJCYuJY1mPlKKX KUuLi7+W8eoqBLYvV3pfrjyiYV3eSMWOl1ED0DDgTC/vUWtjN5fMwbIFHRaTbEYU91uG Pb6hUxOtfrcahL4vnRMd12QgJim+dDCkPst9wM5JrYeAKo4M9YxlNFpKhFcr9gXC9Tf8 Yo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c3uCayXtJzh6uNYCPcqlb3Y3lknaXvEwaqQDHs38NMM=; b=NVWIXm55fFqQcfUEi34dhAIdEHLnIGsKvvtJj1QLUptR/jUNHvBOe6Gfp6EaoxG5AV ADnMYgJGyUT4NbjZSBpCbO8P1h9OcqO9JIoTJCM/AFnCmvIzf7sxnMsmipTQOAxJXVP+ c1danqQkUPRujTyV0Hzz9DyQRB8asio1kgDkvQDd+oA0AkLdB3hiTAmAzmDNPx9OCjax EhYvY4clozSjewMw3NkMbB63rhj2qLiq389ELgQRiBSnlc4ofHtiWE+KZa4zwjA18JHh fSBGLiAcuWDtozO0yVk4WuEYWpQPjKaHFC3Psbynf3YEfFaK1+bc70c/uti+Cbfs7mGd oWXg== X-Gm-Message-State: ANhLgQ1m9iMiJ1+88vMRMvf5K/lq8voTNxdGZqHHK6Zrb2t/Hb8twTGW SdOKDNpbvq8dMPFKNntFvHXq3Bky X-Google-Smtp-Source: ADFU+vsfxo9Yt0JLVkOMfzuVd/DanQZ5EbpUt2/5O+wKZq1lWC93CP2p5RzXAEewJop4yAKzycFKRg== X-Received: by 2002:adf:a21a:: with SMTP id p26mr20927110wra.102.1584848912762; Sat, 21 Mar 2020 20:48:32 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:42 +0100 Message-Id: <20200322034756.29907-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/21] avformat/mpsubdec: Fix memleaks upon read_header failure 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" When allocating a new stream failed, the contents of an AVBPrint as well as a subtitle queue would leak. This commit fixes this. It also slightly simplifies the cleanup process by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- This patch and the other patches that involve subtitle queues should only be applied after https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258790.html libavformat/mpsubdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c index 82c73457ea..8bb1e97b8d 100644 --- a/libavformat/mpsubdec.c +++ b/libavformat/mpsubdec.c @@ -154,8 +154,10 @@ static int mpsub_read_header(AVFormatContext *s) } st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); + if (!st) { + res = AVERROR(ENOMEM); + goto end; + } avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num); st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_id = AV_CODEC_ID_TEXT; @@ -163,9 +165,6 @@ static int mpsub_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &mpsub->q); end: - if (res < 0) - ff_subtitles_queue_clean(&mpsub->q); - av_bprint_finalize(&buf, NULL); return res; } @@ -201,4 +200,5 @@ AVInputFormat ff_mpsub_demuxer = { .read_seek2 = mpsub_read_seek, .read_close = mpsub_read_close, .extensions = "sub", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18326 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 EE84A44BCD9 for ; Sun, 22 Mar 2020 05:48:42 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DFAA268B534; Sun, 22 Mar 2020 05:48:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5C6368AABE for ; Sun, 22 Mar 2020 05:48:34 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id a9so7595340wmj.4 for ; Sat, 21 Mar 2020 20:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zzhcvSjJ2Hd9qnnb+DkRon3HcJk2LV0/jIbyY37+9Mg=; b=uH9LBslieNyaSLgg158ej3wv7d4gH9/GTGzcb2T40cm3vtOFSMYQhnobH4z6zJZBJl NQRaVQmLBp7jYYvSjlz7MmP6ka51mlqEH7hPz2tLlhAr7aV8yCEm+4TYvGUTRBFpIqXp /XOSPHJ0etx7aU/NbLr9siwS6VASVLt7YkxQvi/H1T6g8t6PBNswnL63IHryYNRhHwnR xN6ciMbQE/AGSc59La7k6N/jsjGSMV3871yX83GjUwzIZHbWRevg5eKrmd4fahdUPNqA PkgEauwGkJGvFmjIX1bOSsw+AH/Pd1JhukUt4FXOOtcXyT9PVP80CY5Hjb4IwgrKocfb K5Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zzhcvSjJ2Hd9qnnb+DkRon3HcJk2LV0/jIbyY37+9Mg=; b=ATrg3RJCRgttyXxSXNQcSYEShLryAL9eYEl67s0WgOBWZumSssjJaAYPhpnw/UV+eh 9u+JTFsruvizM+eHg5JPomXvSQY8lCnXQvQl52WmPrEVFrQzIjQ4VO2z0YUkNHRsMUcm HOmByS8LTfsf5fZ64D5nfwvDP/GsxgaEJyWHpcsEP+EEiirsRqEiZ0a8rSa3+hXi67oi FucAkog6nVtw2bmU3F0VgWOOXue66WSSsAU2g+PHBnC/dhjWDFmnxoeZbxDO/ui57aTy x/vPuDKqKZGbNGz+MF/qyJBDNkFemzTYnhNaWIHRTcbr2A8B0C4alKQl1gMuwAp5fMV/ wLpg== X-Gm-Message-State: ANhLgQ1eZ+r1Q9w9Lo0J/OfWBuHJfQerF+6caQakdTcBkxLJtYZvT75g Hv4Cs/hxavjIEYiGg9e7llPwxSJn X-Google-Smtp-Source: ADFU+vvYQeNFyqONPMooMbpYuD69jQ1mm/4Cv2rLccbiEtvDU//2fEZSfO+23GbWQ+Op2HtVYWEh9g== X-Received: by 2002:a1c:5604:: with SMTP id k4mr18504857wmb.57.1584848913794; Sat, 21 Mar 2020 20:48:33 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:33 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:43 +0100 Message-Id: <20200322034756.29907-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/21] avformat/xmv: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/xmv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libavformat/xmv.c b/libavformat/xmv.c index 0c69d267de..288b1e8463 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -149,7 +149,6 @@ static int xmv_read_header(AVFormatContext *s) uint32_t file_version; uint32_t this_packet_size; uint16_t audio_track; - int ret; s->ctx_flags |= AVFMTCTX_NOHEADER; @@ -177,10 +176,8 @@ static int xmv_read_header(AVFormatContext *s) avio_skip(pb, 2); /* Unknown (padding?) */ xmv->audio = av_mallocz_array(xmv->audio_track_count, sizeof(XMVAudioPacket)); - if (!xmv->audio) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!xmv->audio) + return AVERROR(ENOMEM); for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) { XMVAudioPacket *packet = &xmv->audio[audio_track]; @@ -214,8 +211,7 @@ static int xmv_read_header(AVFormatContext *s) packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n", audio_track); - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } } @@ -227,10 +223,6 @@ static int xmv_read_header(AVFormatContext *s) xmv->stream_count = xmv->audio_track_count + 1; return 0; - -fail: - xmv_read_close(s); - return ret; } static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb) @@ -592,4 +584,5 @@ AVInputFormat ff_xmv_demuxer = { .read_header = xmv_read_header, .read_packet = xmv_read_packet, .read_close = xmv_read_close, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18329 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 9314044BCD9 for ; Sun, 22 Mar 2020 05:48:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D75768B4CF; Sun, 22 Mar 2020 05:48:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29E9A68B505 for ; Sun, 22 Mar 2020 05:48:36 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id w10so12306046wrm.4 for ; Sat, 21 Mar 2020 20:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eru00p0zGYxAOAePnAdQkC6xgoZd+uexI0QggvZ5Af8=; b=rgGu3Z7DyFkEdqoX5mY457JqY80xwww9rRW0Old9r8037UWXG7+9e/S3zB5auf+lrl VsPUgs0oEabtTGGlahb/LG1JGl6gQvvlr4nlBwPCZLt7lbZhBEbV2sUZ+jS5uXH3bJ3U BFFbvXzujXNi79A8B6GgmtPxmXI/5MJ7PJV4AJLq6Dv0WjEkuX9KmGoqyRZwX6wBo2tB eoPG2Eg1N2Km/+QJUyy49xtMGbxGKwX5ZPVU0xODtwuAgscWuuyfQGFZF903GO8iKtWI 9mWzycWvghrk43mhOLn2M3vkvnfWCM1ax8UzNn6ls0hUrVM8uMn0iIjrvGTYL715IlUD C58g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Eru00p0zGYxAOAePnAdQkC6xgoZd+uexI0QggvZ5Af8=; b=Tr/bHv4PcLSpxXWMRJAdbMhNPCPJm7d2njEAzLBQGOQ2h8bNjtRH35Bpgqjouagv1F iOm+dJRs/Ku8Gm6AcwDhvNtIhPLCavq8l70tMA+1PGyE8QYWaMpVXCXPxqdGTMD8KTvs 4HTNF88JlMR2xSMz8soLBOQCLfDmBMtqEZgxNJzW9oZNXAmPBLd3gWkJxZ5ZqGjrlVAo JTrBIci+fXkRfTgTIx1zUXtEzcgKEDvPSTsXJvvY5ONXjcX9tlvVZjXGJ3nUm93GByhW r5zCipEiEZnbhqygnzwPIdeBOApUJwcM1hNiRVOYP9SRmbRFRLGdgUlc98UpG+igSjDa 6/BA== X-Gm-Message-State: ANhLgQ272QLRUZrl/33vd6CNsgrcaKXN2UBahMvJwV9v2vystsYnzIzS w+VoIqHxgpBGuQKkCyUWLm1N5g4M X-Google-Smtp-Source: ADFU+vtBzJaJSkK26/CXWyP2WfnFmqiGAC8hJP+GV09r5AhVgC1HFED3kaxApSmB/FYKb9i/DQgYCw== X-Received: by 2002:adf:ef0b:: with SMTP id e11mr21840988wro.115.1584848915349; Sat, 21 Mar 2020 20:48:35 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:34 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:44 +0100 Message-Id: <20200322034756.29907-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/21] avformat/nsvdec: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/nsvdec.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index eb26b29450..a0f1d698f7 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -211,7 +211,6 @@ static const AVCodecTag nsv_codec_audio_tags[] = { //static int nsv_load_index(AVFormatContext *s); static int nsv_read_chunk(AVFormatContext *s, int fill_header); -static int nsv_read_close(AVFormatContext *s); /* try to find something we recognize, and set the state accordingly */ static int nsv_resync(AVFormatContext *s) @@ -495,30 +494,25 @@ static int nsv_read_header(AVFormatContext *s) for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) { err = nsv_resync(s); if (err < 0) - goto fail; + return err; if (nsv->state == NSV_FOUND_NSVF) { err = nsv_parse_NSVf_header(s); if (err < 0) - goto fail; + return err; } /* we need the first NSVs also... */ if (nsv->state == NSV_FOUND_NSVS) { err = nsv_parse_NSVs_header(s); if (err < 0) - goto fail; + return err; break; /* we just want the first one */ } } - if (s->nb_streams < 1) { /* no luck so far */ - err = AVERROR_INVALIDDATA; - goto fail; - } + if (s->nb_streams < 1) /* no luck so far */ + return AVERROR_INVALIDDATA; /* now read the first chunk, so we can attempt to decode more info */ err = nsv_read_chunk(s, 1); -fail: - if (err < 0) - nsv_read_close(s); av_log(s, AV_LOG_TRACE, "parsed header\n"); return err; @@ -743,4 +737,5 @@ AVInputFormat ff_nsv_demuxer = { .read_packet = nsv_read_packet, .read_close = nsv_read_close, .read_seek = nsv_read_seek, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18331 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 DB6DD44BCD9 for ; Sun, 22 Mar 2020 05:48:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C19DB68B59C; Sun, 22 Mar 2020 05:48:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 20DBC68B527 for ; Sun, 22 Mar 2020 05:48:37 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id t7so7594420wrw.12 for ; Sat, 21 Mar 2020 20:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G6bc0odbhMkZRLwVUM/lyQ8gtcVSz0gMkiIklcXf+uI=; b=dcAm0iRmy0MPvhYwiUwYX+gxFcr7tjG05EwbNUVOpAYje79qWD130Gu0HsyGdDGsX7 XbVEPQP0Z/VEUxnOWcG2OSsOdNdK0Cno5PehzKdYGDI68FObb7dv7W6tCC6EcI/Dr77Q mxPd96dBtzu0+gyny+PPaJeD5il2jH6rPXLDaBg36Z/syCwwrwiugW1G9wVmXVg7AtJI Y8rgyAvdjwDbF00AUEKK5uGaDwKqnhqvbDQUFeOTemlwU/t34zX8z1+DVoL1XEAq8N5s /DSoZE7Vnh8EnpOX++3s10EudEdAKS47nJrAw1WsKn/wwS6Z5jpIT3/SkDa5GrJaOcsP GMxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G6bc0odbhMkZRLwVUM/lyQ8gtcVSz0gMkiIklcXf+uI=; b=riBWzsy5gg9le3SoRuKG5oWBvNiNh8fXo5S0iMKkdynsbundW8e8wKKv3uqxlxOLSp iR0Ah6NoAJ+Asr1uRJMK8K5mN8zURuj/4xV5pzy5SK93bbZe9ZTHqic5rRKUCSs8+yEa gM++6Af1jmL2qC8W5LAOUf2thorJ/75ex0strzJiFo+WKmOtoO/UbyR5/Jgj92+vyCJ2 c/tYgb1qzvhLKKEHEsvfQObZNgMvbNnl7uxo8paUKQj7edjWvdxyyZ4LQzui85ACgKc8 n4tSo7TCnmQcOWYeAmRMGs4jFQgkKyj3hQZG4yRs0OY6UqXJMGs1+I96gSFoadPAfhub 4pvQ== X-Gm-Message-State: ANhLgQ3mDVmZeYyy+wGsYuUmz9UZRzcH3moCeBd6TbdpOKHfObzCfZYj 8LGryyt1G0yLkACXehg+KA/ilf+4 X-Google-Smtp-Source: ADFU+vt38ebaRtOs/nA8RiC+BxB6gRPJ8QEWmtAF5j09Br4Z9wGDeu/nMHolgFMT85GphYiIiE1nmw== X-Received: by 2002:adf:9bc4:: with SMTP id e4mr11771258wrc.341.1584848916326; Sat, 21 Mar 2020 20:48:36 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:35 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:45 +0100 Message-Id: <20200322034756.29907-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/21] avformat/brstm: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/brstm.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libavformat/brstm.c b/libavformat/brstm.c index ca965ed7e1..22d862ae43 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -92,7 +92,6 @@ static int read_header(AVFormatContext *s) int64_t h1offset, pos, toffset; uint32_t size, asize, start = 0; AVStream *st; - int ret = AVERROR_EOF; int loop = 0; int bfstm = !strcmp("bfstm", s->iformat->name); @@ -266,16 +265,14 @@ static int read_header(AVFormatContext *s) for (ch = 0; ch < st->codecpar->channels; ch++) { if (avio_read(s->pb, b->table + ch * 32, 32) != 32) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, bfstm ? 14 : 24); } } if (size < (avio_tell(s->pb) - pos)) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, size - (avio_tell(s->pb) - pos)); @@ -284,8 +281,7 @@ static int read_header(AVFormatContext *s) chunk = avio_rl32(s->pb); size = read32(s); if (size < 8) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } size -= 8; switch (chunk) { @@ -297,8 +293,7 @@ static int read_header(AVFormatContext *s) asize = b->block_count * st->codecpar->channels * 4; if (size < asize) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } if (b->adpc) { av_log(s, AV_LOG_WARNING, "skipping additional ADPC chunk\n"); @@ -306,8 +301,7 @@ static int read_header(AVFormatContext *s) } else { b->adpc = av_mallocz(asize); if (!b->adpc) { - ret = AVERROR(ENOMEM); - goto fail; + return AVERROR(ENOMEM); } if (bfstm && codec != AV_CODEC_ID_ADPCM_THP_LE) { // Big-endian BFSTMs have little-endian SEEK tables @@ -327,8 +321,7 @@ static int read_header(AVFormatContext *s) if ((start < avio_tell(s->pb)) || (!b->adpc && (codec == AV_CODEC_ID_ADPCM_THP || codec == AV_CODEC_ID_ADPCM_THP_LE))) { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } avio_skip(s->pb, start - avio_tell(s->pb)); @@ -349,10 +342,7 @@ skip: } } -fail: - read_close(s); - - return ret; + return AVERROR_EOF; } static int read_packet(AVFormatContext *s, AVPacket *pkt) @@ -467,6 +457,7 @@ AVInputFormat ff_brstm_demuxer = { .read_close = read_close, .read_seek = read_seek, .extensions = "brstm", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; AVInputFormat ff_bfstm_demuxer = { @@ -479,4 +470,5 @@ AVInputFormat ff_bfstm_demuxer = { .read_close = read_close, .read_seek = read_seek, .extensions = "bfstm,bcstm", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18324 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 4374444BCD9 for ; Sun, 22 Mar 2020 05:48:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2ACCF68B510; Sun, 22 Mar 2020 05:48:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C97668B4B3 for ; Sun, 22 Mar 2020 05:48:38 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id j17so8882237wru.13 for ; Sat, 21 Mar 2020 20:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Crsg7zgHrrPQVzszHiC7LMNXjX5m+HTDFD64UPiRD1c=; b=DpBTdSleUizUVO6/EGJ6mL1RVaHFkgX9cyzARlPAJAWaMf+0Rx70DQpQ03AokbH9K4 XSCeogBaCE/OM2j1F6cUSzxHsUCJbl1gPpbEO7HNknhxPzgeRMvGw7QVuZb0E/OnhdFZ tDW2V8AcZhQQiXSe5tlg7qUb+tPFa7z/NStxFUfvb4hJhc9L7GquXEn0yfrvOYjJgIlq LGzYc0lTdmNeZTW2uO5JSzSnMX4yeLAGIBHMVnjCYATJg7WY09CFuFf1rlBjYAMopArq FMS4ybAzSmgek3MGtXb629CZtJ6IRBm3HguPh5sPnzLHUEvdQ4F9TqYuARRdaJ9OqnaP l2fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Crsg7zgHrrPQVzszHiC7LMNXjX5m+HTDFD64UPiRD1c=; b=BMV1z482kJVqftd3ZPkXv9ae/Pzpy71veTWKhcWnrVDIMQuekEIzsFTHtjPBX/IgAr uk6Pkg8DcnmJGJdee1J36fYBhkn7Z0jUqgWWdlPXc8dyHn2f69YbPRUJWP8vaac2im2A +4VbzRkT+iLycpMvZkSLl3WsiqOdIn1ApA+BsoG67FMOOzcXqQZtZFAlxSxT3Z6212Xy ffQ0fFGVUKQbYwAP/1ucPHK4Lqj0TCGm2wBdVtDKbeHclPZRRn7W4drh6Px8ODDIKQJp u1xjPNgnf3NJn3Eq+7osWeCDUUyKYeX4tAocRwaPrn1Cfd65vYzo/UFlkbC+DwC2JGGY Z4jw== X-Gm-Message-State: ANhLgQ3AIXzVsQeapeeekCrfn/qI++ElHh30vnbEs0CkNGbwbWqWo57+ JOITSmpEaYye3FIDCocPcFK9IGDL X-Google-Smtp-Source: ADFU+vs5dBxrWx1qcxf4bdgDC2m0dkW+LoR8SFstG+t7KFbDrtX2sP5HgO5BBTOSFB7zfzVOjyQqsA== X-Received: by 2002:adf:90e1:: with SMTP id i88mr21643015wri.95.1584848917327; Sat, 21 Mar 2020 20:48:37 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:46 +0100 Message-Id: <20200322034756.29907-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/21] avformat/jvdec: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/jvdec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 551f8069e6..efa034c9ce 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -114,7 +114,6 @@ static int read_header(AVFormatContext *s) jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame)); if (!jv->frames) { - av_freep(&ast->index_entries); return AVERROR(ENOMEM); } offset = 0x68 + ast->nb_index_entries * 16; @@ -137,9 +136,6 @@ static int read_header(AVFormatContext *s) - jvf->video_size - jvf->palette_size < 0) { if (s->error_recognition & AV_EF_EXPLODE) { - read_close(s); - av_freep(&jv->frames); - av_freep(&ast->index_entries); return AVERROR_INVALIDDATA; } jvf->audio_size = @@ -263,4 +259,5 @@ AVInputFormat ff_jv_demuxer = { .read_packet = read_packet, .read_seek = read_seek, .read_close = read_close, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18327 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 CBB6444BCD9 for ; Sun, 22 Mar 2020 05:48:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2ABB68B56A; Sun, 22 Mar 2020 05:48:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4787668B4F9 for ; Sun, 22 Mar 2020 05:48:39 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id t7so7594453wrw.12 for ; Sat, 21 Mar 2020 20:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zi4fVUPbTzEtTZ/+51yWzKtofuvdqaezrUoU5bcPD5c=; b=oAyAGrSCqBK77Gx0qdbnQ6S6TJlA47NV+q3bkGbTwRLUGHKIxM5ofAd+BB/Rmxcd40 23Dwnw4Fbf9e5IiCZueVeGfhaexwvVDcIUGnLCdm8JCL5SyPjIzw9kyD6sAtmgr8Dan+ YJ2cGI8Rgfsf0wAWlsA3sMhL+3Vf4FSY9DO7lxQmNrxRF3Zvf+tSt3GBE62HvTo5xHTm /edEuNp0WfEyYR9pltKXzFzuNSmtzirOGgpLA0LY/KVK7JwG/fZZMskmkjuSMAYL3pRc QfxcdBOD5ECqbJar/+1RX8jxAZdsEEvPgtgxEfC9SQFZ+99xyzTtlmr0ZBvLR9n6seWs jv7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zi4fVUPbTzEtTZ/+51yWzKtofuvdqaezrUoU5bcPD5c=; b=ZEoOC0y2Ke7mDcBym0Wy/cnPASL0zsr4QJAsmCLBHFc0e2GMgcZHg34J8S4rI0ld5b /rGzXy0WfDLWvnSEYMkv6bwn4zbDAqZCM+9QCdCrslM6tpu6TK+5I0E7qGV6iazgPi34 4b885SGZ78GH5hT4FeqkV6wMOQSBD5TdG1O0M45UY7a2PF9idYE47/CxRcArNu6ysteH MDuyiCSFhO6XnI1m+sjllud4ZqFqLV/Nu/VtVSKqt2jK2e6a3sNUeNNW23OpaZE2cMo1 9BfNVz6H1jG4V607MLXb5iXWZEDsv4zn7t1gqpvKO25jMuAJh8VwFIx7Nd1IWZo8KDY+ Vq5g== X-Gm-Message-State: ANhLgQ3w37XxeALsKcbm6N6Ig2sTxluMI4zaCm8AuxRZ7MBtwwq1buUR 6Ky7cZlw6b1bmY3mgPAwxRjjuNHY X-Google-Smtp-Source: ADFU+vuI4qvJIDA1k3mZz7WRwfWJGpgof/d7YA402IXSkAJHR43Rph9vKyRdafkfPSZ6WAJBjWeEQQ== X-Received: by 2002:a5d:60c2:: with SMTP id x2mr20614236wrt.123.1584848918588; Sat, 21 Mar 2020 20:48:38 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:37 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:47 +0100 Message-Id: <20200322034756.29907-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/21] avformat/nutdec: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 3779dce2a8..260dd514b6 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -805,7 +805,7 @@ static int nut_read_header(AVFormatContext *s) pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1; if (pos < 0 + 1) { av_log(s, AV_LOG_ERROR, "No main startcode found.\n"); - goto fail; + return AVERROR_INVALIDDATA; } } while (decode_main_header(nut) < 0); @@ -815,7 +815,7 @@ static int nut_read_header(AVFormatContext *s) pos = find_startcode(bc, STREAM_STARTCODE, pos) + 1; if (pos < 0 + 1) { av_log(s, AV_LOG_ERROR, "Not all stream headers found.\n"); - goto fail; + return AVERROR_INVALIDDATA; } if (decode_stream_header(nut) >= 0) initialized_stream_count++; @@ -829,7 +829,7 @@ static int nut_read_header(AVFormatContext *s) if (startcode == 0) { av_log(s, AV_LOG_ERROR, "EOF before video frames\n"); - goto fail; + return AVERROR_INVALIDDATA; } else if (startcode == SYNCPOINT_STARTCODE) { nut->next_startcode = startcode; break; @@ -852,11 +852,6 @@ static int nut_read_header(AVFormatContext *s) ff_metadata_conv_ctx(s, NULL, ff_nut_metadata_conv); return 0; - -fail: - nut_read_close(s); - - return AVERROR_INVALIDDATA; } static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos) @@ -1304,4 +1299,5 @@ AVInputFormat ff_nut_demuxer = { .read_seek = read_seek, .extensions = "nut", .codec_tag = ff_nut_codec_tags, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18328 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 9CD9944BCD9 for ; Sun, 22 Mar 2020 05:48:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C21E68B573; Sun, 22 Mar 2020 05:48:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D140A68B49C for ; Sun, 22 Mar 2020 05:48:40 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id g62so10649901wme.1 for ; Sat, 21 Mar 2020 20:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZSp8QoftobIG8K/bFWcHjIOXCt0pFBA6q2ZA7o6rbcI=; b=k54eckBshRRPqVKCHlckUWq64UezDbDKq2gGS4svpdKibmGZO5ri24PS7S5Ss+em1/ mEa/PPI9flAobQ3xK6nwhorBZ/MBj2s3SGnyOi01A/kSDc1crWNfZdcHTiZdBVh/hBWV CNFSK7cBn8+2HX59GLRC1EeXwNqvW44YX+bTPnB5JxFEAhGNa6pYooQxgWd2ZjzsxopF ccL1mA/wHxfbVJ5DtmfCBLHdiW4aoLvLs49zm60tyoYCQ9n0DIYxB7larbNmjz1CT5YC ozt+1ChwKT+MSgvTPxarNl69Q2fSXeuZYSTPTIH/jEPw1lcL1oCM4HerCpHZgCMCUiV5 OudQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZSp8QoftobIG8K/bFWcHjIOXCt0pFBA6q2ZA7o6rbcI=; b=O0Do2vDHnxXpVapAhSXSNbRDchbIdxIROZ3qB9Ci3Wfqg1K4Li/vJ/jTH95g3Q6Xwe wBxEZLSFPoJt2kCZTVuZXpXZrcRSF0BWWjnBlf7nuJ/yQfS8mbhTTHAQHARe97X/SBQm byZZpOrSQJGyXzR1TrQEA7tZySGhyd5ihVHCrB8sWle4t1b4HlHBMkoO81YNd9xiBG1w TBQnE1y8CsRyyQjtkGugMlmiWVyA+WsxIYmkIJTJYBS0pfEi411lB+5P6nVsDMiOc9rB ru93GK1jTxm0yQSVsDjERLwEL6F1VbsbVV8WWXjn6ir8pJ3x2KoMa7UjSIYtmxqdjCos 7M/Q== X-Gm-Message-State: ANhLgQ0WXkk3o2C4UiwhzvrELxn+/VdYGEHh9+ZYZNVu4bw2vItKnPbg eiMpwpqOhpexY+EuXPDzmxu3F1Ud X-Google-Smtp-Source: ADFU+vu0a7RXW+GqlxJvqhqBjY+guw0P1r4uSe8+j9xGpjW2V95WPV9tluG8xPJXhgOS/wUkbjtBXw== X-Received: by 2002:a05:600c:286:: with SMTP id 6mr19348277wmk.101.1584848919858; Sat, 21 Mar 2020 20:48:39 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:48 +0100 Message-Id: <20200322034756.29907-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/21] avformat/av1dec: Simplify cleanup after read_header 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/av1dec.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c index 1be2fac1c1..3bf7b598a0 100644 --- a/libavformat/av1dec.c +++ b/libavformat/av1dec.c @@ -174,16 +174,10 @@ static int annexb_read_header(AVFormatContext *s) return ret; ret = avcodec_parameters_copy(c->bsf->par_in, st->codecpar); - if (ret < 0) { - av_bsf_free(&c->bsf); - return ret; - } - - ret = av_bsf_init(c->bsf); if (ret < 0) - av_bsf_free(&c->bsf); + return ret; - return ret; + return av_bsf_init(c->bsf); } static int annexb_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -276,4 +270,5 @@ AVInputFormat ff_av1_demuxer = { .extensions = "obu", .flags = AVFMT_GENERIC_INDEX, .priv_class = &annexb_demuxer_class, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18330 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 9B43F44BCD9 for ; Sun, 22 Mar 2020 05:48:48 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84BAB68B591; Sun, 22 Mar 2020 05:48:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BF4B768B4CC for ; Sun, 22 Mar 2020 05:48:41 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id l20so10653682wmi.3 for ; Sat, 21 Mar 2020 20:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KRRVkBTLmqvt2LlnLIqLOCOk1bpz+04IowtFXeFjC1Q=; b=SSts9WD01380nhUkYxLaq8VFwv/JOcewdgusAErXLR4Cvm2uud+5WUVSsXmsz0Rjx0 QKBj686wJBf15KIJF2W2FhPlZ9Q6shtQdv3MAH7RtNBcxAtb6e2TlOV3yaIFAILdVUbi oBpCQUXCx7rPEVbEr+U6TfLP9ZVQie0n/uOyhDcwyq8XXvPQws6Yh+8Jv/EBEbtRQ+Ll O+uAbAwqOl4iAB27rlMRhf5BFeHsymp0NXIgg6Oe5R0o68t+qRtuLWFYzXOi5lwv73gz 79BkbQic6edMWbRSzQYjqb2Y0c1mG1OZ7srbz56Cl+rQs8JQPp2U9P5bIOB4uC1LLC4X Qy2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KRRVkBTLmqvt2LlnLIqLOCOk1bpz+04IowtFXeFjC1Q=; b=Tu3qMn0dDt0WMN55p1nElrJEyaVCoA0RDoZfDpP0eQ2sFr9qguFHLDrfpShea6xbJR OhlyQ68WoCaN4Jgek8RjMxAxJitPHLM282p7AoE5Ma3RCUiBDhwRzJFbwukQK6awquBp zcDXPpd+2112VDN/Vac/kMNwqLiH6ZqHqqn7OnHl3CPO9kImn1tFH0DfgIt/2kZmQpn0 pqGZt0N2GNIGY48g/EUnMThFAhOceHmnOyHv4vXAxzEaCOLhGgJFUVF4zSdWNVpWe3lj 1W6H3XJ0JgXnAm01tWzoRlQZEEhOabqONZZOo8cgxqA5SGJ88j134UJrIIUDL287P6Jz 5UQg== X-Gm-Message-State: ANhLgQ2wZ5O0GK/cvxwRh3MtfFTLtsyUt3OzgXzqpb+TTW1vRZA6eF9g bg6fgNWyTb7y10koQKOeywnpfJOC X-Google-Smtp-Source: ADFU+vtnIJ42wyND0JUYzHUwMp2hpLN/Mez/Xc2GHcPWRGL064Bo4HtGKPrQrGZyoh81YiBQ/HSgRA== X-Received: by 2002:a7b:c0cf:: with SMTP id s15mr20165291wmh.106.1584848920782; Sat, 21 Mar 2020 20:48:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:49 +0100 Message-Id: <20200322034756.29907-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/21] avformat/microdvddec: Fix memleaks when adding subtitle fails 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" The subtitle queue could leak because microdvd_read_close() would never be called to clean up the subtitle queue if inserting another subtitle fails. This has been fixed by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/microdvddec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c index 08e6fca09c..668e317e4b 100644 --- a/libavformat/microdvddec.c +++ b/libavformat/microdvddec.c @@ -204,4 +204,5 @@ AVInputFormat ff_microdvd_demuxer = { .read_seek2 = microdvd_read_seek, .read_close = microdvd_read_close, .priv_class = µdvd_class, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18332 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 985F244BCD9 for ; Sun, 22 Mar 2020 05:48:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83E5268B59B; Sun, 22 Mar 2020 05:48:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8705368B520 for ; Sun, 22 Mar 2020 05:48:43 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id w10so12306130wrm.4 for ; Sat, 21 Mar 2020 20:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c/cLo8p4OjrRQdTgdgiKWOSuvdE0j/YdVQdvqmVRA74=; b=ivwSShjPKZJKK204uuIuIbA/8RV+WnWo4GlSwsf7V5ljrEwD2VqeG2MWLQK6SW68GB hWQptT+NrqrlQdyfwmXT2Y3YtaZ6BBqOQ1kG9JesfhtyUmWhKJHLLb9BxDf3gw8yIUKb q1wWQFahB8HbYrYO05fGrg8ifdl8OQQ3CQ2aimJUUp4bZog3YMCor9qe+HNOJ0BEM9va 7MjkPxi4j6tnsfgLywr4WIgLC/xMBkeolofniOEBYSJvyWFvh6K/PAm+B1QZh+ThLIhQ vB6+iMZCzPIPKUFFeJuzoMK7rLF4mCz4F3AHdSZbRZYpurtKWmF/YauDmZQx7svSzMfc QynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c/cLo8p4OjrRQdTgdgiKWOSuvdE0j/YdVQdvqmVRA74=; b=mYtAEgjAS8aAzCTN8TMArlA5XbCJxHdXSW95SQsn1bSN772NzCMvg0STUk1mpCO8UW bTHPBPwEW/SCTKyx7yzMxiZ2IxnNsOqC+nes9ElAtJRf4Lm7TI0DBxddeZGmDYH15fyq UQOAkxC79pFT8GKdr3rJbS/cB18V6jojdYsGU9Fqp3MqA8ChGyEyW4c7/+p1xJR8pXq+ kGjrLArVqNxeVd+MnpEYwIHvmR2x7UbJZ6aDYIM75lO8sLqK5UmZPyix+FZWA0ufRVUN sKLP3R0B8j1SvzhoIcsKc9ojLadqwoQIhXVDCEGxyoXThb+SOksnm41ADUCX+drx2AE6 2x/w== X-Gm-Message-State: ANhLgQ3fxRihVcMGsF/78GwFcCnSyjoOGPMCANVQ4Z2SflEi630u3qpU FIjeXtWXKrfXwa1GC7+WGdejxYY+ X-Google-Smtp-Source: ADFU+vtYJmNG/e2s8BTjT2UW7CQu+Ck7lm7ISkcafTOr+ApFYfXekl7kDKX0OQhzhrec8VgI3aC7qQ== X-Received: by 2002:a5d:6a4b:: with SMTP id t11mr20891611wrw.52.1584848922575; Sat, 21 Mar 2020 20:48:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:50 +0100 Message-Id: <20200322034756.29907-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/21] avformat/ape: Fix memleaks upon read_header failure 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" Several buffers allocated in the course of reading the header would leak if an error happened after their allocation. Fix this by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag so that ape_read_close() will be called to clean up in case of failure to read the header. Signed-off-by: Andreas Rheinhardt --- libavformat/ape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/ape.c b/libavformat/ape.c index ed6752a415..81088bbc02 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -470,4 +470,5 @@ AVInputFormat ff_ape_demuxer = { .read_close = ape_read_close, .read_seek = ape_read_seek, .extensions = "ape,apl,mac", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18333 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 74EF544BCD9 for ; Sun, 22 Mar 2020 05:48:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64ED168B5CC; Sun, 22 Mar 2020 05:48:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A2C3A68B4A3 for ; Sun, 22 Mar 2020 05:48:44 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id 26so6207195wmk.1 for ; Sat, 21 Mar 2020 20:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wr60ynPyUPG/lea2jXLiNriab44RZR7vyRdWlscjLxY=; b=BrQpUwDB96/Y/nyOtnCEDppdlv5A75XIG9Fe9Y4fTxR3kK734FXbxptTzcc5Xn5L2c pKhkTryu2q1ofM94wYoVhEy+enwtQkTNSFfAwhz9qF0eg8HjeFVd3ZAsNWQGlFJBzSa/ EK+QqhStgRCADC2eNILKhZ+InqZKWORzSg8l98n8dczb8g//21ArB6t52VSw1Jc1PI4V Bm3PrGC3H5Jh8TkFzFGWWzccQA0b8aMj9fH5iCMIQGXSBnhH+9tyKFpbeCuW4bdlyWd3 Cqzfm71/i+gayhem7e0tZCD8yZlmhTjczctmVAjeBH/x7mIh/T1oi9yY78kLn8hJCzzL PmXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wr60ynPyUPG/lea2jXLiNriab44RZR7vyRdWlscjLxY=; b=EZTw4vncXPzSmbj7qMRqYYnHCQ1/K/h5tqg4whH3M+9XWj/MCs6vumdsZn7w3SbVmN dC+Vhfu0aCYBz01iTKsmhBv14ZJki3lLYHDiTWPFF0GlD9eKYQO1pyF5cL6fpjVHmK7r VIVum+Yt7w3CBaQo1K4TP+zR79F0t2xAvSLGQ/+sJ3bHa9TwK4XB2I/K7G5fUFwVuijV iYLRVdhyrQj1lUhpp+neSHXLGtLXLLV462OkDrKzlnwIK3u2YwThEieZKuGOXKsYnnin oLpfdKAcIn0SqfqE2jm2/CU09/JhpTZzV4mNukwmrArDW9sHdVisiPTEjyFYIt1874o7 dlqg== X-Gm-Message-State: ANhLgQ33ASeENU8/uppOpSvHT5xWz1zwgccspNDSwXveYe3iXJmnvYsT ZIuSsUPP2P61Mwu5jcRc7eN6IvGV X-Google-Smtp-Source: ADFU+vs27M5iqw/xvHSaIwGHS8PQHGAKqyWKJnmnOMV3pDSUfikuKZSW9uprRvU1WEGvh3ni868drQ== X-Received: by 2002:a1c:5452:: with SMTP id p18mr19955154wmi.102.1584848923722; Sat, 21 Mar 2020 20:48:43 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:51 +0100 Message-Id: <20200322034756.29907-16-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/21] avformat/aqtitledec: Fix memleak when queueing subtitle fails 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" The subtitle queue would leak in this scenario. This has been fixed by adding the FF_INPUTFORMAT_HEADER_CLEANUP flag so that aqt_read_close() is called if reading the header fails. Signed-off-by: Andreas Rheinhardt --- libavformat/aqtitledec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c index 8cc82a8f39..191a31b2f1 100644 --- a/libavformat/aqtitledec.c +++ b/libavformat/aqtitledec.c @@ -145,4 +145,5 @@ AVInputFormat ff_aqtitle_demuxer = { .read_close = aqt_read_close, .extensions = "aqt", .priv_class = &aqt_class, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18334 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 99116449790 for ; Sun, 22 Mar 2020 05:50:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8188968B589; Sun, 22 Mar 2020 05:48:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6E8868B549 for ; Sun, 22 Mar 2020 05:48:45 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id w10so12306168wrm.4 for ; Sat, 21 Mar 2020 20:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qNWkGAGbw3wwn0uzEdhGtFwKZnjFoiIv91ua0N1tYec=; b=pREdT2GN2QuflCZf6DM7Xd1YdZH+zVssZR+vlS1BBA4vI0dHvSFOs719vg06xjrrGY XRwDn0ROR0vN8p1V1s4BCJQcb+Kl1Frt6Y8wPgwSohthmQr3ybx9MrPGBQODBm7ntgyn Mh6ksV+K6RzJr/yvPMwzJQg/vYjJiu14ZuvcxEUF4dosEhKELrAPOfhl3cVNmF9QKR2q ENsclkH55tl16wIwtr1xDSoy4HMG7HgE5Pm36guXoAdosw48pMm66ZXAnN3XbzD60qAL mC7ykm5qQeoShrWbDDXAz9EzJqxIkrHe9A0x0ioLd+BeDUrnOjzlUugt3lDgyGD6eiaz zXqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qNWkGAGbw3wwn0uzEdhGtFwKZnjFoiIv91ua0N1tYec=; b=QLPxUwY6o1mEZsggoxysh8RKoZAjL3CbNsEtvERZsdI9mIPnG4vcsIDS0Z9fZkASmX laEFjejyACrZpcsPpwwpUzQu0ZteVl4XsdvBShuzKf0Ed8CYzYoLoKVxDqVkw+z+JmKv lTdxfyEKFvKhTkcZ1G2aj938EytYoCA0hAEuIOYtvwFee0WJqJZJPJQqIQ1KqQPhG3Id GdJ7lS/2F+M8duDftfB/OHdkuiB/gzNW+A3fEzk3mvzLiYO38gHiHZRgM74L7FCtkAp5 rSDeYywl4n4f4ZskAWiWzCbLdk25RQJi6Pmo4/zeCZ0VmQlRX8rOgMJCi+TWyklYPKED IRMA== X-Gm-Message-State: ANhLgQ3jUy/mYwtlglQogUiIzyqYh00JE4vSS0rpCn/W9Oslq2Y6DG9F A2UCYx2qOoy2eBf5UfqKkMqqTf+/ X-Google-Smtp-Source: ADFU+vsB4EcT1m286R7JkS5gNkjjvA3+BS4tU+1ZbRy258lSjhWRUcTRyHm2rBdZ3cPYhualA+kf/w== X-Received: by 2002:adf:f310:: with SMTP id i16mr20632671wro.100.1584848925115; Sat, 21 Mar 2020 20:48:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:52 +0100 Message-Id: <20200322034756.29907-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/21] avformat/jacosubdec: Fix memleaks when queueing packet fails 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" If inserting a packet into a subtitle queue fails, said queue would leak (because jacosub_read_close() which frees the queue was not called automatically when reading the header fails); moreover, an AVBPrint leaks, too. Both these leaks have been fixed, the former by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/jacosubdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 121c86d659..3e30118b8b 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -188,8 +188,10 @@ static int jacosub_read_header(AVFormatContext *s) AVPacket *sub; sub = ff_subtitles_queue_insert(&jacosub->q, line, len, merge_line); - if (!sub) + if (!sub) { + av_bprint_finalize(&header, NULL); return AVERROR(ENOMEM); + } sub->pos = pos; merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n"); continue; @@ -233,7 +235,7 @@ static int jacosub_read_header(AVFormatContext *s) /* general/essential directives in the extradata */ ret = ff_bprint_to_codecpar_extradata(st->codecpar, &header); if (ret < 0) - goto fail; + return ret; /* SHIFT and TIMERES affect the whole script so packet timing can only be * done in a second pass */ @@ -244,9 +246,6 @@ static int jacosub_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &jacosub->q); return 0; -fail: - jacosub_read_close(s); - return ret; } static int jacosub_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -272,4 +271,5 @@ AVInputFormat ff_jacosub_demuxer = { .read_packet = jacosub_read_packet, .read_seek2 = jacosub_read_seek, .read_close = jacosub_read_close, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18335 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 F039A449790 for ; Sun, 22 Mar 2020 05:50:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E2C068B54C; Sun, 22 Mar 2020 05:48:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2FED68B57F for ; Sun, 22 Mar 2020 05:48:46 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id d1so10639065wmb.2 for ; Sat, 21 Mar 2020 20:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cDF1ewrS74Hi9qolHbkEGCt+sBC0gTVWWWI7/0o0m/M=; b=OlkZVSpVO4KC+NLPRKtO6x8vO8vBlPz9Qftbmo7z2PzaUVLCLP5YbkX9IK7VW/lbfi rU4Ti9eY+uKlDMUP3rrK0ZP3G9u5HPZjkfSb9rcyX6kwv+Y07c0IHHoY8SDaHZHfdwUX QTzl+nIwZDSQUkzPLFkHPZ273gEX7wngrhu3Gc8+2+Ej472ucmnT3o0CAuvzMts0Twvt 5HW2q/ijC+s4YM0xkKJ6gVnI2AjEzJJhYKLNTKrHpZRMZEVBwFHOt+CFb9I/4Y+2l/MU mK+B3C4DBP1F2wxbiAhQGqCaOWQIbILmlqkX+qhTB1sncXpuxx1YDt9tSvzJB5ybCgt0 Jt5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cDF1ewrS74Hi9qolHbkEGCt+sBC0gTVWWWI7/0o0m/M=; b=aJMS3lpMoQuOVXyAqGdI5SAUlt9CvRwY7fOXUJ22Hp3sVuZsWn/e+ivJI9C+/5Cp9v FFzjq+I1iPft1uonsPTgYe/gf96eJYV4kXZFQ+xNe6FQlZdjPLA5/Obq6423X/yYx3s6 UuAm3Ayy1VuMZgeRkGvTu82NP28baEMaKkBRqg1I8tbvy0/LdDo0I2/KU1VuKXnkkbQY WVrFWPyonGDRNHWerM0jFBDIog4TPZqdlW/AC4se0mPxFFAf5eMzF9DOUjFC/Vgd3rOu ilDqXdASb2wST8+imfvASGvN9fY6tY9SpPdAA4BK4EXpsDEYRbRAKRdw15jBcT7wHay6 Rnzg== X-Gm-Message-State: ANhLgQ351P4KBJGKyhVPsod/AurEpcRSz2eFsRsNqmIdabT8T3DA/CIq XwE5KQFUOHvfMTf/cHBqTvL9E3kD X-Google-Smtp-Source: ADFU+vvspIcBkq9giYhOWkCu8FldGSqnnW/yEsKknPd4Tn3xyUgVudPZJp3McRKqbxu1j0EaLy7XaA== X-Received: by 2002:a1c:1d8e:: with SMTP id d136mr5520754wmd.26.1584848926091; Sat, 21 Mar 2020 20:48:46 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:45 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:53 +0100 Message-Id: <20200322034756.29907-18-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/21] avformat/assdec: Fix memleak when reading header fails 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" In this case, the subtitle queue would leak because ass_read_close() is not called automatically when reading the header fails. This is changed by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/assdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/assdec.c b/libavformat/assdec.c index f66b296673..d9e0af264a 100644 --- a/libavformat/assdec.c +++ b/libavformat/assdec.c @@ -189,4 +189,5 @@ AVInputFormat ff_ass_demuxer = { .read_packet = ass_read_packet, .read_close = ass_read_close, .read_seek2 = ass_read_seek, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18336 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 8C25A449B66 for ; Sun, 22 Mar 2020 05:51:07 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A9BF368B5C2; Sun, 22 Mar 2020 05:48:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D05F168B4DE for ; Sun, 22 Mar 2020 05:48:47 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id f3so12278933wrw.7 for ; Sat, 21 Mar 2020 20:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LTxI5ZoKkjnO887Jl0tm0fMH2J1HAOE3c21ss12J66s=; b=dddYS4mK2v/id0YXmLemprJPOOGdfk+hKgy2H+CkuT8urX0nzZNOI8NSNUUeqHwICP s05lB23TxBBHWQNiVS1vQi1l6wyj7Qa2U+xpzSWheMW16t7M/jgBn0TmixrvCCG4AC5m 52Fao5UnLzF88d8NnVVCERFpTwXeHUZ4MFULj9eOmr1IF36xReYEuezttJjEep7jt4pF c2cIM8rjARXM/uRcD/XCfp8YsEiON5W5J6nKRMLUfOA9cYdCwesKZjmRtfepB3NGLtLz xk4X92gjVjb7p7Qy00CY/4nWbpDOi1nE3UToqlWIc8+7Mxh/v60/rNmUwg3YuHR2DtuV eStA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LTxI5ZoKkjnO887Jl0tm0fMH2J1HAOE3c21ss12J66s=; b=I2fGQDEH5ft5yMh5YJBuuimTFC6ymIXmODsbl57gVcoCYg+9yPm7sQkvv2x3/kgxnS pTB/ycNZ6HtvdPHH6+EuRS0Pf8VDz+PRNU1sN0A8j+CzmsxSeb4hW/G6RW9LakWgWT/o oGDZ8f+W4ADFrdb1TB76yUzdZkNxDVu4CIiTvYScPsfkWGzJGKJMmzyabsANLuEjN2AY v4wKQ0SF6iMt0Y3rmuioQbjek0IdW4802kkV4m2ihBkdEbXsYdx4eLAmf0wZaefAIteC 93rNF5h9w00ea+1+sUDlzIvQqvpr91/Ur6v5EjxGTgvIN9ZEalXirLh5/sIDjIPf6fAf T9IA== X-Gm-Message-State: ANhLgQ1YypvtE9JMa2XFzx+Ud0TIp50Yudm9h0pdAwcP8RsLP+CRZypg AxyTysyL+81oCCnyqgpGmcVTlGG5 X-Google-Smtp-Source: ADFU+vt/Wgom3oz0QSvIvpmpNaVSKrtKm/qfDzXFkMSiyHUhGc7ytdFiUP+xbHv+Pf7e9q+ckspdWQ== X-Received: by 2002:adf:ec4c:: with SMTP id w12mr4742082wrn.240.1584848926982; Sat, 21 Mar 2020 20:48:46 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:46 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:54 +0100 Message-Id: <20200322034756.29907-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/21] avformat/tiertexseq: Simplify cleanup after read_header 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Also check error conditions for being negative instead of only nonzero (they couldn't be positive here anyway). Signed-off-by: Andreas Rheinhardt --- libavformat/tiertexseq.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c index d7719e5acb..07c939a4d4 100644 --- a/libavformat/tiertexseq.c +++ b/libavformat/tiertexseq.c @@ -161,7 +161,7 @@ static int seq_parse_frame_data(SeqDemuxContext *seq, AVIOContext *pb) err = seq_fill_buffer(seq, pb, buffer_num[1 + i], offset_table[i], offset_table[e] - offset_table[i]); - if (err) + if (err < 0) return err; } } @@ -202,20 +202,16 @@ static int seq_read_header(AVFormatContext *s) /* init internal buffers */ rc = seq_init_frame_buffers(seq, pb); - if (rc) { - seq_read_close(s); + if (rc < 0) return rc; - } seq->current_frame_offs = 0; /* preload (no audio data, just buffer operations related data) */ for (i = 1; i <= 100; i++) { rc = seq_parse_frame_data(seq, pb); - if (rc) { - seq_read_close(s); + if (rc < 0) return rc; - } } seq->current_frame_pts = 0; @@ -224,10 +220,8 @@ static int seq_read_header(AVFormatContext *s) /* initialize the video decoder stream */ st = avformat_new_stream(s, NULL); - if (!st) { - seq_read_close(s); + if (!st) return AVERROR(ENOMEM); - } avpriv_set_pts_info(st, 32, 1, SEQ_FRAME_RATE); seq->video_stream_index = st->index; @@ -239,10 +233,8 @@ static int seq_read_header(AVFormatContext *s) /* initialize the audio decoder stream */ st = avformat_new_stream(s, NULL); - if (!st) { - seq_read_close(s); + if (!st) return AVERROR(ENOMEM); - } st->start_time = 0; avpriv_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE); @@ -324,4 +316,5 @@ AVInputFormat ff_tiertexseq_demuxer = { .read_header = seq_read_header, .read_packet = seq_read_packet, .read_close = seq_read_close, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; From patchwork Sun Mar 22 03:47:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18337 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 2BCC7449B66 for ; Sun, 22 Mar 2020 05:51:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A79C968B696; Sun, 22 Mar 2020 05:48:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0507668B589 for ; Sun, 22 Mar 2020 05:48:48 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id r7so10431147wmg.0 for ; Sat, 21 Mar 2020 20:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nR16Je0kTgMU3aW9/iw0o92SMHb8ViNmCFzCB24BroI=; b=G6GqEaNSol1oWD6np8n932P5Ri3RORnIYov/9hhHmXRBp98xq6QfHqW5Fk4STvcXDT 7WGJQleEVQkXCsv/poar4XXlfXmTfRcBXstc3IkJpJaI/BaDvlmI9MvAchELJCTnzpmv HibKCdW1RAwXADxjdpt4CQGHv6gcrJF2vJiCLFOBzkxcEjvkFcG4PIjXzhapOMg86efJ K+LiP0q5sNvO+QPuJ+WaXwquVMfr+VSakhOb8/IeW9ARphaYx9wK7goEOmqqZ2ujyBpz rFGMgs0GS0c6pPWCGOk0kTI54S47xJTcIXESsskavjmi1kvgY4I7T0JAaXK0hG3zjteY VjfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nR16Je0kTgMU3aW9/iw0o92SMHb8ViNmCFzCB24BroI=; b=gMyWZtC/UOdHIqA5OI7zkBJPtkC4/Db8pSlPcrmOEOAdvq5gS2QdsBBQs060gZq4NG 3fUpES8aHhYbHjPkhkjRE9LtZ8tG+wtSH13zRirW70+p7kx4RUf3BPIxcnkRxewHRMEp BvAR95Rve+/Doik9cKZ1GrtXAaBw1IThz/g8ElBDt4jmWQ50dA5rjwMC7WDMZLqytD5C 7yZF3I/wBay2GMx8r+GuU2GCIon7zTDX+iS5p7R6iXNcaQtWH8XaYNBgsAL7Bz5nIekd RqqnaaqcIRayXlMrk9wa80EdN+XPnqIa6fAzuscke/4KL8rzeri/mBuisdls4KIqHepL XYkA== X-Gm-Message-State: ANhLgQ3296K1faANcVKdfrwgUD1N3NLGoLntImEhk5ipNqucFIm+LBtO cnbp2nQhueTtGCeQYjWzpFSpqYvv X-Google-Smtp-Source: ADFU+vtyFbPDAO44x0VBIdMXlnr+tj1WX6YcwcKM9eq4C9edXsljQlNWVO4niRJ+QqLPlkZ6fd04bQ== X-Received: by 2002:a7b:cc8a:: with SMTP id p10mr19124026wma.10.1584848927976; Sat, 21 Mar 2020 20:48:47 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:47 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:55 +0100 Message-Id: <20200322034756.29907-20-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/21] avformat/mpeg: Simplify cleanup after reading vobsub header fails 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Furthermore, also remove an unnecessary check for NULL before avformat_close_input(). Signed-off-by: Andreas Rheinhardt --- libavformat/mpeg.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index eba5852266..f21507dc63 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -720,8 +720,7 @@ static int vobsub_read_close(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) ff_subtitles_queue_clean(&vobsub->q[i]); - if (vobsub->sub_ctx) - avformat_close_input(&vobsub->sub_ctx); + avformat_close_input(&vobsub->sub_ctx); return 0; } @@ -765,17 +764,17 @@ static int vobsub_read_header(AVFormatContext *s) return AVERROR(ENOMEM); } - av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); - if ((ret = ff_copy_whiteblacklists(vobsub->sub_ctx, s)) < 0) - goto end; + return ret; ret = avformat_open_input(&vobsub->sub_ctx, vobsub->sub_name, iformat, NULL); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", vobsub->sub_name); - goto end; + return ret; } + av_bprint_init(&header, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); + while (!avio_feof(s->pb)) { char line[MAX_LINE_SIZE]; int len = ff_get_line(s->pb, line, sizeof(line)); @@ -908,8 +907,6 @@ static int vobsub_read_header(AVFormatContext *s) memcpy(par->extradata, header.str, header.len); } end: - if (ret < 0) - vobsub_read_close(s); av_bprint_finalize(&header, NULL); return ret; } @@ -1045,5 +1042,6 @@ AVInputFormat ff_vobsub_demuxer = { .flags = AVFMT_SHOW_IDS, .extensions = "idx", .priv_class = &vobsub_demuxer_class, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; #endif From patchwork Sun Mar 22 03:47:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18338 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 C590E449B66 for ; Sun, 22 Mar 2020 05:51:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7FAF668B4C5; Sun, 22 Mar 2020 05:48:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9354668B5B0 for ; Sun, 22 Mar 2020 05:48:50 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id d198so4851805wmd.0 for ; Sat, 21 Mar 2020 20:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJn+KZou1+8OoSRiRtoibzqOt+Yp1q/PQ4qvzFZ4PtA=; b=Jk01g/1kMCz1rjP4roABjRNeLHa8Tel69nX35lqT5PCUPItDAo1clhH4LGQvzLgn7J RggOk4gtSiDIkbHn1U79elmNaDysXZfAqz1KIrXGfznN1gJp9SZm0BM7ew0ZkysGIIMi O7Nc55kKuh6NLBM6RO6X7CnWNCl8skfiGmCQQBybS+Gr2WVYUAUbv4KrhZF6HFLYB8k8 l0hqjniHKSvgoMwnPgTaq0gBaQ4b904t4Q38sgCIrOYqhiX58HK70vX54WTNn+0Hnn9U p7CqH9TTtBCcmmBUQ/LoT1cYQpUXkgEn0sGbVyLa2NlL4hGRiStRtOBP42v3z9GTysXi IPlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OJn+KZou1+8OoSRiRtoibzqOt+Yp1q/PQ4qvzFZ4PtA=; b=lyActcdW9Y3XCZPoVvZEv36tCNE6w6t/4FYSMDEfj2AxAhUIqP4KzRyNEESFpdLKJQ Q9lTR+wbS6ClTaojMLX0MnXDf9iyQGmxZK+vAxLsB7wmoa79/hJnFDWr57hIbTvV0aNS ea288yxACXyT674x6NKESpRWm1lnYj5Npp6NPSzGZmqAEKGOTbmdqkREoGhHAKwK5wcT TXmk/TUcz5i5VK+xeAsyXw6tOXjML1jbrogFl5ALqp7Xy+UVqGrCwmqGxWe1UcHySKZ7 rNgClSPd1q6rCKWmJg56KXFX0vFRN+v6SB8WhFynbDx6RUrw/3166+2MMDbInlpBju3X MAmw== X-Gm-Message-State: ANhLgQ1DSGKgeiMQjqXzCtjNTVKdY5EX+bp/s0tg0IPNdo7dGaQIoShM 3jBgxcLM1VVB5WuH/iq+InPTjK3m X-Google-Smtp-Source: ADFU+vvx4Wz32LfAtTVpY0B37w4BwmVuou+pDslrosd/xiTyOsppczduDhUXpA5mKCohqUEMyCgkmg== X-Received: by 2002:a05:600c:2901:: with SMTP id i1mr13288732wmd.177.1584848929715; Sat, 21 Mar 2020 20:48:49 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id k204sm1530371wma.17.2020.03.21.20.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 20:48:48 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 04:47:56 +0100 Message-Id: <20200322034756.29907-21-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> References: <20200322034756.29907-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/21] avformat/icodec: Simplify cleanup after read_header failure 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" by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/icodec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavformat/icodec.c b/libavformat/icodec.c index b47fa98f80..9449bb7315 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -96,10 +96,8 @@ static int read_header(AVFormatContext *s) break; st = avformat_new_stream(s, NULL); - if (!st) { - av_freep(&ico->images); + if (!st) return AVERROR(ENOMEM); - } st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->width = avio_r8(pb); @@ -113,7 +111,6 @@ static int read_header(AVFormatContext *s) ico->images[i].size = avio_rl32(pb); if (ico->images[i].size <= 0) { av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size); - av_freep(&ico->images); return AVERROR_INVALIDDATA; } ico->images[i].offset = avio_rl32(pb); @@ -130,7 +127,6 @@ static int read_header(AVFormatContext *s) break; case 40: if (ico->images[i].size < 40) { - av_freep(&ico->images); return AVERROR_INVALIDDATA; } st->codecpar->codec_id = AV_CODEC_ID_BMP; @@ -143,7 +139,6 @@ static int read_header(AVFormatContext *s) break; default: avpriv_request_sample(s, "codec %d", codec); - av_freep(&ico->images); return AVERROR_INVALIDDATA; } } @@ -224,4 +219,5 @@ AVInputFormat ff_ico_demuxer = { .read_packet = read_packet, .read_close = ico_read_close, .flags = AVFMT_NOTIMESTAMPS, + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, };