From patchwork Sun Jun 14 22:36:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20353 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 6F3C244AF2E for ; Mon, 15 Jun 2020 01:37:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4B4AB68B2E0; Mon, 15 Jun 2020 01:37:15 +0300 (EEST) 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 B91E468B029 for ; Mon, 15 Jun 2020 01:37:08 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id r7so15195112wro.1 for ; Sun, 14 Jun 2020 15:37:08 -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=VjCkHN+zdEjl3H8iTEQ0z42yePuHOTeHV743bLkW7aw=; b=cTlT3TRO+R2q/liPsLVhrUPts+CWNr9ShnC9K/LvWVlePJHgU1k6GjjQgCfe6Hw24z eP5G7Yez9Vn/ioWW1cfPIVtKJzRuoM/gks8gjt75pJqtFDpUjxfkJ0gPZ+vdBPwrTklE gwBsuFmy5gWBpPnSVzIjacYueeCp2nivlWvCHbvelG79/kzFFT+RCk1y7LhhuUQoXITO jPlZG14j5uMvpp4YlXhwE7vHQOLdQBqplagbSeO2/I88gXLLRK37JKQd4IpxirQ4ZtHG kjJP7YKDQX6gN/iD4/hnf3RYOq/Nm4UcYH09oKnF5kwNLaTSJS1AZ4hf3LeqtkHMM935 zneA== 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=VjCkHN+zdEjl3H8iTEQ0z42yePuHOTeHV743bLkW7aw=; b=m3zXlFBJsb+jKod/nkd0amgzsJCQdfFWcJPaPiFJNtY4yEktIWy1h8VdQbeM8I5DSu N5mHuB19yFAbcyV/8Jf2iimvB//+aHebC6ULHOwSZyFqmIx3Mm4YAuBRGRzsqAUy517D TNaerDZLzPUsiX1lFh8+h/uLHhzcLCgCZrnmKtt6Z66nSBaF99ULJuhBDpXToA051zTw F7GoCK55ek7V+PcxR8Kaii63/3Ay2qF07uuUJS8sT7Qpdmg8yd2o4RhdFLwZU1MNP5PS XACPx6c79t5QRxmKSwi8t9pwF/CIWSfdecFsTrEY+RTABCsc1lguKltm5VspfCswRgB2 Lg1Q== X-Gm-Message-State: AOAM533XM70AhA0MicNQIrbLckwjbOsN0PxxF1ee5Yz39VbMk+DmNXVS O3DRHH0uijcD2hIUKgehcSbfiiDJ X-Google-Smtp-Source: ABdhPJz6tQtR7D4Q2gkepV1MShyQ00id0vv33hIN6e0ZmMH4oqOdFnH/fFHOK1q48Tp7dImxRMX21w== X-Received: by 2002:adf:a283:: with SMTP id s3mr24397134wra.147.1592174227951; Sun, 14 Jun 2020 15:37:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:37:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:31 +0200 Message-Id: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/26] avformat/matroskadec: Move AVBufferRef instead of copying, fix memleak 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" EBML binary elements are already made reference-counted when read; so when populating the AVStream.attached_pic, one does not need to allocate a new buffer for the data; instead the current code just creates a new reference to the underlying AVBuffer. But this can be improved even further: Just move the already existing reference. This also fixes a memleak that happens upon error because matroska_read_close has not been called in this scenario. Signed-off-by: Andreas Rheinhardt --- This fixes one of the memleaks that I found during the work on my patchset [1] that intended to automatically call a demuxer's read_close function if reading the header fails. Several other of the patches of this patchset also fix such memleaks. I intend to apply this patchset soon so that 4.3 can finally be released. [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258831.html libavformat/matroskadec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index bb3a126c29..b1da40983f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2938,9 +2938,8 @@ static int matroska_read_header(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; av_init_packet(pkt); - pkt->buf = av_buffer_ref(attachments[j].bin.buf); - if (!pkt->buf) - return AVERROR(ENOMEM); + pkt->buf = attachments[j].bin.buf; + attachments[j].bin.buf = NULL; pkt->data = attachments[j].bin.data; pkt->size = attachments[j].bin.size; pkt->stream_index = st->index; From patchwork Sun Jun 14 22:36:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20354 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 8DDC8449042 for ; Mon, 15 Jun 2020 01:38:07 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6FB7268B4C3; Mon, 15 Jun 2020 01:38:07 +0300 (EEST) 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 76EA168B20F for ; Mon, 15 Jun 2020 01:38:00 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id x6so15129238wrm.13 for ; Sun, 14 Jun 2020 15:38:00 -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=BU6SEaO6dgs6XY5KfDUDL9jXBxUw97trgTDx7tId8Wo=; b=RUPL4/RftuzKlGVUJqrWyAnlFl0d2f2D6mynDcOuHb/jEbewFyhx2nz/GAZePuWxmr 14HfMSN1YQC384yEx4VbflSD3HnqeI4xQOeXZB6Yj8ypsYDDuUc5k454zsyGAD3Y73xx UawmrlEb4fNw2s6esLLDAxZm4d/2mw30dTinHFP0d0O4U9YntGBdxh0GIi7NtZ1QFqd1 HzZIBeu8r/KbaG/dt4yLk1js4P/S999jZj2/gtWkDDuU1C4yik2qC14jlD5ofuxij+jr vMZJAr61XALj0/VSIr1xiGxe47Azz1WCBIBD2VjyRdJ9X3PJlPpPzZdoOz+qMNz/Q6l6 WOfw== 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=BU6SEaO6dgs6XY5KfDUDL9jXBxUw97trgTDx7tId8Wo=; b=XeLjronKovEYFkgfgdIkNLMpAMHwk4QaGGNQ4/Tnnc6j3D5WoXT9n+Mf/VLkYkizmt etwM/70aX3yt5CpnIDC6d6aypyPhP7p8kZA1zWFDl9VDEerP2rU1LCXHN0glPOngDcKt KOrgZHRD4YododWQFd1BpZ2UrHcVmW9EGrhNbxZ9H7bA1fyIuEgKB3DMUR/ugXXGPVFd R1PwjjLAUDffGXbsEpZva897OOWZaG3MKTGPgXNX2Hgj2D4y8lFxv9xBCGrl9gPtGK+A +UjMY0MVGGvEelJtTeq0Ta5+fLpXYombPLyElHRdL32QDK0wTAPO3n2+6CMer7ZI8MrB qSCQ== X-Gm-Message-State: AOAM533FNdbvWIlkAj1T9/4HEmeluh8OYV/ud/80YQAzoXxoj/i2RPOq 31bLdFcjrLkX5bm92d9Q4QpyoUOp X-Google-Smtp-Source: ABdhPJxrLeIGW2V5Bg8NiOnExc1jxq2xPZ9rk6Hmm5aRjDRxINaTbycVZ+mkVNnQICMyzuk47LTpuw== X-Received: by 2002:adf:f84d:: with SMTP id d13mr24040764wrq.99.1592174279742; Sun, 14 Jun 2020 15:37:59 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:37:59 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:32 +0200 Message-Id: <20200614223656.21338-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/26] avformat/matroskadec: Fix handling gigantic durations 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" matroska_parse_block currently asserts that the duration is not equal to AV_NOPTS_VALUE, but there is nothing that actually guarantees this. It is easy to create (spec-compliant) files which run into this assert; so replace it and instead cap the duration to INT64_MAX, as the duration field of an AVPacket is an int64_t. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b1da40983f..1846b1f93c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3568,7 +3568,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf if (st->discard >= AVDISCARD_ALL) return res; - av_assert1(block_duration != AV_NOPTS_VALUE); + if (block_duration > INT64_MAX) + block_duration = INT64_MAX; block_time = sign_extend(AV_RB16(data), 16); data += 2; From patchwork Sun Jun 14 22:36:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20355 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 88E2A449042 for ; Mon, 15 Jun 2020 01:38:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7173A68B494; Mon, 15 Jun 2020 01:38:11 +0300 (EEST) 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 A57E868B2E0 for ; Mon, 15 Jun 2020 01:38:04 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id h5so15196021wrc.7 for ; Sun, 14 Jun 2020 15:38:04 -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=4e3iCvjz1Cv5wvYkP+tONHBsRopuLU7UFZ14xgXBwng=; b=mIK7EpIZa/GtfFlJ0ZKWbtxmH01HL+1nyEnQ2WeGwpr9H55SOVO5gpwnGXwUS+fSXE p12SLyFTq9yiOfL8NGB1+O+0AceMvotWR4N47/N3ejOMs7713La53ycc/G7yLfV8bwmb RKo+avDXxAupLBUt3csXLx4HCvv0IExQkofYgdU62IozZ6NHN2pWS4izaUfiKuhUezxQ BYd/0sIVK9a84GyEOGNVHHg81S9flI6iSE4XykFAI5+sZupaCgzyfCTaAxFmlA2z5ue1 jRx5ExWYIppk3ZoAg8o3Tr6c3MKX5q9/6Efqhhk451yu/Cu+hiMHcjTxyEKAEBe+fPSP KUnw== 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=4e3iCvjz1Cv5wvYkP+tONHBsRopuLU7UFZ14xgXBwng=; b=SqV5222NeGAcCdW1AcHVmFOw871A7tOzodrZ0T3k+1aiYXu5xMOtCKBwhNDzAtC+fS ocjouqOGt1NVSmPl9a0JrwQ2eMVM7cOrx4jCXDP0o3P0+KtL6Fd/ylhJD+eZU2Ahll3c K65sa4DxyKddYdnGp8930+q9tYe7TH88LTsCbGwIaiVegu/Lp2Cavb2OKx8eImsNEeWq grsH5iumMV6auBVYKGURmlc7M6o+UtOxcjt/H5EEV4jh321OlZ1Uuw5yA+dFz7w7Egbc oW0+0YURqC8hkS7krrXkmjAbY6Gz2DiyTbMWV+M3j0O6+dck3E3qT/JBD9a+Q5J4k9FN 7nwQ== X-Gm-Message-State: AOAM533LU38X6fibtXLj2hDY3H1E039HZK3xmf3tiKhr+kyWCsfLsw7b vqrUFF6kyuSL/aO13V1RRZMbffIW X-Google-Smtp-Source: ABdhPJwQ70HDn23chTolxnE8RvO0QMoSY9NBBEuxFi2wBw5FROwmio3bF/kMTpLAyvdUerCnomQs9Q== X-Received: by 2002:a5d:6444:: with SMTP id d4mr26561278wrw.239.1592174283869; Sun, 14 Jun 2020 15:38:03 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:03 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:33 +0200 Message-Id: <20200614223656.21338-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/26] avformat/matroskadec: Use right number of tracks 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 demuxing a Matroska/WebM file, streams are added for tracks and for attachments, so that the array containing the former can be NULL even when the corresponding AVFormatContext has streams. So check for there to be tracks in the MatroskaDemuxContext instead of just streams in the AVFormatContext before dereferencing the pointer to the tracks. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 1846b1f93c..d26375cdcc 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -4180,9 +4180,9 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Failed to read file headers\n"); return -1; } - if (!s->nb_streams) { + if (!matroska->tracks.nb_elem) { matroska_read_close(s); - av_log(s, AV_LOG_ERROR, "No streams found\n"); + av_log(s, AV_LOG_ERROR, "No track found\n"); return AVERROR_INVALIDDATA; } From patchwork Sun Jun 14 22:36:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20356 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 4AECB449042 for ; Mon, 15 Jun 2020 01:38:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33D3968B553; Mon, 15 Jun 2020 01:38:14 +0300 (EEST) 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 6B8B968B310 for ; Mon, 15 Jun 2020 01:38:08 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id j198so12855898wmj.0 for ; Sun, 14 Jun 2020 15:38:08 -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=D4fEZO7ava6m+rxWlYkfEM3gC6OwiFsSNYpNSIcEwGA=; b=PALk51KV2bXFy02CnAHaXIqcCbNmQDBGBG2u19NXYE7j0AcMB/N9tNMH9ml1/0f6eg WybOCcCR9/605oWUoj5VFM3j4UVXBSPeSKerUe/SI/HYzqslNOZuFv3/TbKKOUrEicb7 toBIx2LnRDKRHUvQSbhjkMLBcJBo+BTAxThtwrC3iBJbRots87MbGUEglMFI52Sh+ctJ TqNOvEYVbQsRTvK+ujWVm7qRQSZ4E3hyZHVtAsDEbd0sf406jMYeWkpU5nFzqatFtXAE kUHEhudphLmm7bCRZXtPDG2o1IWNgASCZVIQxrXt21XcVbHWZixwRg7K5nN1dAVwo3E7 K67g== 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=D4fEZO7ava6m+rxWlYkfEM3gC6OwiFsSNYpNSIcEwGA=; b=WzO5QsSohqxZh2NampmjsexNSKsMKaq0d40Xtkk96tSVQpVg8PxqYg/HbgaTKpI33l f/zNWhiBOdFG4EwLA3modh4K61f2XaomRSgZwLYQZ5RiA/TMe4EapovewvzE6Z32/LtK jTSzsr02bNtIVaZ3o5O4oCOYUSehNFfdNDyATXEQr/dHaeTtCCi0QMG1jq2Mw9zl6WYx W8/IkpsYEW5sHwmmf54DBBmb9G6EAgwuke2lGD1ech6OtdU9nngmzzlkrmedC81mbKxk /EjsER5pXwPzioddI32Xqa50hYk7PNMI3rQf5ueaVIOsQC+xcYRANk6kl0rYDsxpwIus q66g== X-Gm-Message-State: AOAM531Iw1azVArYP5ixVFIo7hQpoYK4I7zflDFoxgdTI482uNZd4CPF jre75nlcsLaRqDAcVhVuPZdfx7Ru X-Google-Smtp-Source: ABdhPJw/sSFZUe2jyX9XXBNfsNPNAl5B4Lz/4TEZE+y3qS8CxQMD3ZxJ6ksG/PMasTjS0Q3j+SKOfw== X-Received: by 2002:a1c:bcd5:: with SMTP id m204mr9365569wmf.146.1592174287644; Sun, 14 Jun 2020 15:38:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:34 +0200 Message-Id: <20200614223656.21338-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/26] avformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer 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 certain error scenarios, the underlying Matroska demuxer was not properly closed, causing leaks. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d26375cdcc..44beedb4aa 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -4181,14 +4181,17 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) return -1; } if (!matroska->tracks.nb_elem) { - matroska_read_close(s); av_log(s, AV_LOG_ERROR, "No track found\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto fail; } if (!matroska->is_live) { buf = av_asprintf("%g", matroska->duration); - if (!buf) return AVERROR(ENOMEM); + if (!buf) { + ret = AVERROR(ENOMEM); + goto fail; + } av_dict_set(&s->streams[0]->metadata, DURATION, buf, AV_DICT_DONT_STRDUP_VAL); @@ -4211,7 +4214,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) ret = webm_dash_manifest_cues(s, init_range); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error parsing Cues\n"); - return ret; + goto fail; } } @@ -4221,6 +4224,9 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) matroska->bandwidth, 0); } return 0; +fail: + matroska_read_close(s); + return ret; } static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Sun Jun 14 22:36:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20357 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 298FA449042 for ; Mon, 15 Jun 2020 01:38:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0DAC368B597; Mon, 15 Jun 2020 01:38:42 +0300 (EEST) 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 2E68068B2E0 for ; Mon, 15 Jun 2020 01:38:36 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id r7so15196529wro.1 for ; Sun, 14 Jun 2020 15:38: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=i3GrLoWYHqPgb/32uWZO8Ct1sDO+/jI0oJ0S1ZoGtUk=; b=Xq0rfGfo10CMWTLH8QY4dSP8k3A76ceQdfqE4VGZimsSzWgY5AlxBLRMe82JzHqjZd KV+Xz4Wuh4rzLYRDUNp605TPxzbrv5cK7kOP9GMBHta2DzL6dH/eAmcrOHOmiO61z8W3 dvv0aOaXMfgp4iNQ7ZF+9eEMpucRTpWegXr+hNcDtm2TMUP6A1HjBQ9iFBmRmxF4mfYP 5xmhspxPtGkE9/JxMM81DnlBLryo9HXLbAnzrwthLD8lwNkBKz2Nh/bkJGZJwhO2P3ee cJtcNRXF4YtFe1Kbmg+RfUpKQkbpNFkmUhtfmY3NnS1STFPNL5vdmXNtv0BS5Mi9f4h+ ZGvQ== 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=i3GrLoWYHqPgb/32uWZO8Ct1sDO+/jI0oJ0S1ZoGtUk=; b=h6M03l+0Mc+p/cTCoe/+sXahn2+Urb0bWbItyTTZ+P3jB5uNynC7ph+9ITVm32bDHN 1t2Dy0prD2lSO1BNxX9hcMjMGhcZpIl7F78aYWb5OAcFqXKj//jxFGqUuDzIs7TQ9fvW 7QFZltmn2uf1BusyOGCni4vdckNCWRy2D3Oaw4eMNVzCKNQYbmBEfzxF4V33U1XCttcg 98jxec9sl1jh9JFNHl0J6uPEmNE2DVgI2DBELvQEh30Bm4WYfg9ReHJYC5iI1pajPBPd BsILqlArvjVh079MMQyIejliMrdrnIzC1ZuqpPB2glsIicD6iYTuYaxokUgQAC2znXZM 3UIQ== X-Gm-Message-State: AOAM532IjnPaXpVk6S8+YkLPjyUZOVJ9rFxxbzl5B9CO+oV5oytHuNim vSNJoUuZxJbMnHeaAuurSpOjJYsB X-Google-Smtp-Source: ABdhPJw52y4w2HY8yymW86HCuBCqDe3Fm4454Z6LVz7sSw8vM0DdCGXLONnxG4PRicUYDYcs1tmNNQ== X-Received: by 2002:adf:f582:: with SMTP id f2mr27811401wro.204.1592174315363; Sun, 14 Jun 2020 15:38:35 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:34 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:35 +0200 Message-Id: <20200614223656.21338-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/26] avformat/omadec: 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" Fixes possible leaks of id3v2 metadata as well as an AVDES struct in case the content is encrypted and an error happens lateron. Signed-off-by: Andreas Rheinhardt --- libavformat/omadec.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/libavformat/omadec.c b/libavformat/omadec.c index c6b3f8bc2f..5675d86e75 100644 --- a/libavformat/omadec.c +++ b/libavformat/omadec.c @@ -79,6 +79,13 @@ typedef struct OMAContext { int (*read_packet)(AVFormatContext *s, AVPacket *pkt); } OMAContext; +static int oma_read_close(AVFormatContext *s) +{ + OMAContext *oc = s->priv_data; + av_freep(&oc->av_des); + return 0; +} + static void hex_log(AVFormatContext *s, int level, const char *name, const uint8_t *value, int len) { @@ -402,11 +409,14 @@ static int oma_read_header(AVFormatContext *s) } ret = avio_read(s->pb, buf, EA3_HEADER_SIZE); - if (ret < EA3_HEADER_SIZE) + if (ret < EA3_HEADER_SIZE) { + ff_id3v2_free_extra_meta(&extra_meta); return -1; + } if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}), 3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) { + ff_id3v2_free_extra_meta(&extra_meta); av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n"); return AVERROR_INVALIDDATA; } @@ -425,8 +435,10 @@ static int oma_read_header(AVFormatContext *s) codec_params = AV_RB24(&buf[33]); st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); + if (!st) { + ret = AVERROR(ENOMEM); + goto fail; + } st->start_time = 0; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; @@ -441,7 +453,8 @@ static int oma_read_header(AVFormatContext *s) samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; if (!samplerate) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto fail; } if (samplerate != 44100) avpriv_request_sample(s, "Sample rate %d", samplerate); @@ -459,7 +472,7 @@ static int oma_read_header(AVFormatContext *s) /* fake the ATRAC3 extradata * (wav format, makes stream copy to wav work) */ if ((ret = ff_alloc_extradata(st->codecpar, 14)) < 0) - return ret; + goto fail; edata = st->codecpar->extradata; AV_WL16(&edata[0], 1); // always 1 @@ -476,7 +489,8 @@ static int oma_read_header(AVFormatContext *s) if (!channel_id) { av_log(s, AV_LOG_ERROR, "Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto fail; } st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1]; st->codecpar->channels = ff_oma_chid_to_num_channels[channel_id - 1]; @@ -484,7 +498,8 @@ static int oma_read_header(AVFormatContext *s) samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; if (!samplerate) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto fail; } st->codecpar->sample_rate = samplerate; st->codecpar->bit_rate = samplerate * framesize / (2048 / 8); @@ -524,12 +539,16 @@ static int oma_read_header(AVFormatContext *s) break; default: av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n", buf[32]); - return AVERROR(ENOSYS); + ret = AVERROR(ENOSYS); + goto fail; } st->codecpar->block_align = framesize; return 0; +fail: + oma_read_close(s); + return ret; } static int oma_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -591,13 +610,6 @@ wipe: return err; } -static int oma_read_close(AVFormatContext *s) -{ - OMAContext *oc = s->priv_data; - av_free(oc->av_des); - return 0; -} - AVInputFormat ff_oma_demuxer = { .name = "oma", .long_name = NULL_IF_CONFIG_SMALL("Sony OpenMG audio"), From patchwork Sun Jun 14 22:36: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: 20362 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 23267449042 for ; Mon, 15 Jun 2020 01:38:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07ADB68B659; Mon, 15 Jun 2020 01:38:48 +0300 (EEST) 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 86FA468B644 for ; Mon, 15 Jun 2020 01:38:40 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id t18so15179008wru.6 for ; Sun, 14 Jun 2020 15:38: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=mYq2u6MWS6LEVduNGrTdEimK9wq0ymV9YpACfvmt7h8=; b=VQWIGDp5+O+BZeXJ87b0Eq+iBHrnCBKxxi+dolqYo8xptw/1edQBVzL4fUP6sLY7yK JM7yl9VCH/fV5ZW+KiUldQdFW12OY5D1Vqf3Dw6qBkd1KWNFIQ6lcdrGCZ/pthOoM/qc hdNNHGAGqqyDlmZ+9aDZWlfiaJoZA6D+ZviB3zbAf5GxIAFm/vedv0ErIf1rMzSWZdWl 0H6wz9WTf4VuDYGDXtQzJtwylE512+na5UbIxw66MmNShpHJd4VUc5pjkWNlcsFkFbyC Kr3wOsEr70yCjViH8/ki86VA4OeipJQrL08SpcleLy4kWO1JFQ0dGNl0GDIHEAyeZyDP 1FvQ== 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=mYq2u6MWS6LEVduNGrTdEimK9wq0ymV9YpACfvmt7h8=; b=Hmu6WKkkA2MLHxwUGdgvgM5wylAXgxw53R1omGTc/PVv2Nj4Pt2/h+W3haiZvI4Heb QadBdlfKFP5NAID8FMAUTSVZ244l4tPL2vmC2rs+3DhTzHb0o+CegAQrggLcnONWYnIm 2syRVOos8uLIVg+d/eQSUkk0yk3RS2KLzAUPYN6dkuYWqdF8SELBclETAtsYg7GYdUYV H9bzHYT09mkgR9aK2uj0jvGnumayuklvclBJVggzbJre38UUpH7TGxkBp/PbZAwUEuay B61fNokbt5lKVLuVC/xx+KTW/zZXueRXKN9LWsl+LFSmgdI6tZEIbDQfZA2Z8CGo5xSU 0Hcw== X-Gm-Message-State: AOAM533PvBx12ySZRVPleNbbkp9CK22MQ8EXeXb1TwXirgAQ7SbYTeBY maK9SMq5bTUnQ13fpGs426WjaJrD X-Google-Smtp-Source: ABdhPJyAyvBDCohzg/3YZfnjz9mt4MJYG63FUrfcptxau9FjcgDo3QXagpHGjKgkLuC8sz6Yzu6CNQ== X-Received: by 2002:adf:ea8b:: with SMTP id s11mr26217304wrm.168.1592174319652; Sun, 14 Jun 2020 15:38:39 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:36 +0200 Message-Id: <20200614223656.21338-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/26] avformat/mov: 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" 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 (mostly adding side-data to streams) this has been forgotten, so that all the internal structures of the demuxer leak. This commit fixes this by making sure mov_read_close is called when necessary. Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2fc27d2aec..47bbb3697d 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7580,14 +7580,13 @@ 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; + goto fail; } } 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; + err = AVERROR_INVALIDDATA; + goto fail; } av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); @@ -7640,7 +7639,7 @@ static int mov_read_header(AVFormatContext *s) } if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE) { if ((err = mov_rewrite_dvd_sub_extradata(st)) < 0) - return err; + goto fail; } } if (mov->handbrake_version && @@ -7660,8 +7659,8 @@ 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; + err = AVERROR_INVALIDDATA; + goto fail; } st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration; } @@ -7676,8 +7675,8 @@ 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; + err = AVERROR_INVALIDDATA; + goto fail; } st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / sc->duration_for_fps; @@ -7701,8 +7700,7 @@ static int mov_read_header(AVFormatContext *s) case AVMEDIA_TYPE_AUDIO: err = ff_replaygain_export(st, s->metadata); if (err < 0) { - mov_read_close(s); - return err; + goto fail; } break; case AVMEDIA_TYPE_VIDEO: @@ -7710,7 +7708,7 @@ static int mov_read_header(AVFormatContext *s) err = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix, sizeof(int32_t) * 9); if (err < 0) - return err; + goto fail; sc->display_matrix = NULL; } @@ -7719,7 +7717,7 @@ static int mov_read_header(AVFormatContext *s) (uint8_t *)sc->stereo3d, sizeof(*sc->stereo3d)); if (err < 0) - return err; + goto fail; sc->stereo3d = NULL; } @@ -7728,7 +7726,7 @@ static int mov_read_header(AVFormatContext *s) (uint8_t *)sc->spherical, sc->spherical_size); if (err < 0) - return err; + goto fail; sc->spherical = NULL; } @@ -7737,7 +7735,7 @@ static int mov_read_header(AVFormatContext *s) (uint8_t *)sc->mastering, sizeof(*sc->mastering)); if (err < 0) - return err; + goto fail; sc->mastering = NULL; } @@ -7746,7 +7744,7 @@ static int mov_read_header(AVFormatContext *s) (uint8_t *)sc->coll, sc->coll_size); if (err < 0) - return err; + goto fail; sc->coll = NULL; } @@ -7760,6 +7758,9 @@ static int mov_read_header(AVFormatContext *s) mov->frag_index.item[i].headers_read = 1; return 0; +fail: + mov_read_close(s); + return err; } static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st) From patchwork Sun Jun 14 22:36: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: 20358 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 DACCF449042 for ; Mon, 15 Jun 2020 01:38:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE1F868B5EA; Mon, 15 Jun 2020 01:38:42 +0300 (EEST) 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 A548F68B2E0 for ; Mon, 15 Jun 2020 01:38:41 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id e1so15192571wrt.5 for ; Sun, 14 Jun 2020 15:38: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=KRlutKN36HrJoIcOYHbJ5OmJLR95vlFVPiawMIlTtFU=; b=jeTGqTbrEr3fLdp9LP3IVlznDYEduZFdfQkA1CUYx06GjYalK4TmCyydVbDlmwiAXz R+co40AHkzaz3VRc8oxOlGNmQHmoEHmQhmHRfDKaDDPv8stTbVqHEFTSN/nkJNojpkLY WTAtE5T1Qdv5NUp6ZDojxFfjcXNU1hlNnMox/NlNKc2yh+NVVMNixVuPbatsc8Sd3esx ZXKM2ddQ8zBlcKYdNgfPaktl8ARLnfODQAUO1r+ie1eDaZAOpUKpwL9iRjdnuLLD0mtK UpR+/Zk5MB/ZVs2377pSTjDLeaxC4k0tNX2WEjLrOb0OAeutP7ADlfqSXWiOb1vzRTSY fCug== 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=KRlutKN36HrJoIcOYHbJ5OmJLR95vlFVPiawMIlTtFU=; b=aBqaCw3+ItsEVFv2WbuQb4uXNT8GbRvBpJWKcXW7Sul6t1gOY0xNDc1+SxYc0zpjLS JwR/wbg1gC4Yq3EbEWqang8UQk7+yAO+jYZU02S1BKkxjDRzQxZJniPMSF/7idUKP9K9 YbzZ9vp7hl+eITlIYw2mNTpfZ5aCaX6/Nkb/QLrUFUUERGwhXzAc6SF6aAfLKF75cgYH gukcoM9g6tqnvwLMw7jGrnETCDreS7LEk/x8liPAvy0yyIGYQwUiNnweVJTKtuWVkrlO CaGGF0bnBB3VjZnz0UFycaGdaNFjZwxwTKHDv7dqQxBS9t8rFFZlMUzit6cS4pmwKhsi c9vg== X-Gm-Message-State: AOAM5311IBPbqXOonrgLHXHh9gRaqxUQ4wlE3/dQZ1FrLj7+5wjM/ftD VkwHaXgQCtQILiA0Wt0M6NhqcEfG X-Google-Smtp-Source: ABdhPJwABMs37qHoNd+zPfXYPN8GIP+3LS5xVH0XjcAk2HTF39+oOGgSLIYjgFk3qQ7kqPoYysdWjA== X-Received: by 2002:adf:b198:: with SMTP id q24mr25817657wra.368.1592174320880; Sun, 14 Jun 2020 15:38:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:37 +0200 Message-Id: <20200614223656.21338-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/26] avformat/aqtitledec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/aqtitledec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c index 8cc82a8f39..81630d73b0 100644 --- a/libavformat/aqtitledec.c +++ b/libavformat/aqtitledec.c @@ -81,11 +81,11 @@ static int aqt_read_header(AVFormatContext *s) if (!new_event) { sub = ff_subtitles_queue_insert(&aqt->q, "\n", 1, 1); if (!sub) - return AVERROR(ENOMEM); + goto fail; } sub = ff_subtitles_queue_insert(&aqt->q, line, strlen(line), !new_event); if (!sub) - return AVERROR(ENOMEM); + goto fail; if (new_event) { sub->pts = frame; sub->duration = -1; @@ -97,6 +97,9 @@ static int aqt_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &aqt->q); return 0; +fail: + ff_subtitles_queue_clean(&aqt->q); + return AVERROR(ENOMEM); } static int aqt_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Sun Jun 14 22:36: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: 20359 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 9C281449042 for ; Mon, 15 Jun 2020 01:38:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B14768B61B; Mon, 15 Jun 2020 01:38:44 +0300 (EEST) 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 D4D8A68B5EF for ; Mon, 15 Jun 2020 01:38:42 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id r9so12804436wmh.2 for ; Sun, 14 Jun 2020 15:38:42 -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=b7ld6nP3yYFETD7dlURvVTatRbIOXIcNXpOlDi98p5s=; b=bXIUfmxMkQLwaU8lRd8ltz1GemddVYOAuPZQ8bf8W8OEoIQgPrp/GfwFwnSkPU2xcO SYi7qHl4jhIkT4I1LFMtNaJrdfk+JIGzJI6k9Lmy/WAIexaWYQmK7isDNyrkp8CArvAi vW5NjX5ySdT7kYRFyeDX68MEbqDhkR1ndaM5odGQyFY4GnOBhcZ5OWjq2j8qsGmIeZjp v0oKVTAObzL2STLmlGWK6vrGAcrLEk4QMxh5frTfcAG0xW6QbE2ciJWTbnRgNdkFnoJp mXOyeItt9KOVAx4/H6vGNbs4QuAJY0JwZopnrypHPDUrrhpKENV3llEiMPrfihygXrG9 xnLg== 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=b7ld6nP3yYFETD7dlURvVTatRbIOXIcNXpOlDi98p5s=; b=E8+7LTXUYl7Txo3xr3uIQrGq83ApUABXDkBk15arThevaBS3br3ykAcjwjjLgHGW72 UWAf8fSFZc0UsVdyepaFEtwRPjMTbnNbEjCvFpX0sccrHluh7QBd7bXXgNxDZFvneohv aaHZg2YyoWcOsbzTgoARCsFUROripiDciBNBUQEAV1o1L183NJWGXDjMz27Jvsmr4Qoi MTRrTC+AQ4Eih4Wh4bP5KWbnqjH0veGcvv52G1UpV2tAZyO7l7sRlFi3y0F1PwL1Xizh 2KSj7kX4dXpi0GghFEx/rhUE6lrwq5eSautA4b+5cXip99VHNAIjhnVA0LsdiTSuXX7e 1+9w== X-Gm-Message-State: AOAM533JVIkxvHsYpSquzy0758F5fxOy6aAzF85LpX3LtRLNu1s3hpaR HiB3s5s3HVjtQVTUbtdlECqHnjvS X-Google-Smtp-Source: ABdhPJxXvDghPH68rfskOU9o8XwNCJI+RA/CCSoQTnkgsAw9KCiIOvz1Ghq6827BvEUZmjVYlSwN+g== X-Received: by 2002:a1c:7e52:: with SMTP id z79mr10466409wmc.104.1592174321899; Sun, 14 Jun 2020 15:38:41 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:38 +0200 Message-Id: <20200614223656.21338-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/26] avformat/assdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle or if creating the extradata failed. Signed-off-by: Andreas Rheinhardt --- libavformat/assdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/assdec.c b/libavformat/assdec.c index f66b296673..8fb9e8e501 100644 --- a/libavformat/assdec.c +++ b/libavformat/assdec.c @@ -160,6 +160,8 @@ static int ass_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &ass->q); end: + if (res < 0) + ass_read_close(s); av_bprint_finalize(&header, NULL); av_bprint_finalize(&line, NULL); av_bprint_finalize(&rline, NULL); From patchwork Sun Jun 14 22:36: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: 20360 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 6C846449042 for ; Mon, 15 Jun 2020 01:38:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B1F368B60D; Mon, 15 Jun 2020 01:38:45 +0300 (EEST) 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 C613A68B5C9 for ; Mon, 15 Jun 2020 01:38:43 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id q11so15188452wrp.3 for ; Sun, 14 Jun 2020 15:38: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=WBZM035juMWthU6ufPVH58QmEhvafRaHZv1D7AnvFNo=; b=QLMByg95OewkMPs8EOJ4gjJUrf6o8ZFe9G25NFHKVbJiqKgiaqr8VGFosCQheB+WLy mE463X6N22dS3dn0u6ZizohTI3cM4u8XfmEwZ6ji3/P64p4TMUwwC6bINl/Nu38/uB8G uHj3gFZEUIoakWgmVLFoWwUpMoy+Ox0RclaVG1Oz1TdlOI3Yv1dS+KA/g9zKLFbVa7Gw J1c9T27MyTrWi8kwyizOzO/8+RGW9+ybtPipAZVc4dXI0AM0DLoBmhiCRwxXoVJGpct9 qIdPPoNH0dRuMW8yOOEVrEpMqq7wrZWZda43Ct9UKF213c65rgI+PEqXv4bsF1S9ZsN1 41wQ== 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=WBZM035juMWthU6ufPVH58QmEhvafRaHZv1D7AnvFNo=; b=d4fRwJcLjQmYEfLED9T23DKByU29slAW+OCtiNbCjyc95hTpza8u08ophmRju1oUBW 2YKC603uw4RDx/8WzZPf4L8jA194wq5Bpd1JaZSOdjrnm4xfdGAkNjIxbUqYTLHa1A6/ FMtfceDlV6v/8cEWpxXu49AA7guTUrusDvYEDLu0mFEYi6ithXe+y5zuXx9+F3GJTRjg nJpDiXVKUGHifWUR6kaygHOE6nm0sm+07tk9th98TX9wkKpr7yJHFA5olkWwQfxBQ+wz EShkK95C0hL7nIsVQujaFNYZ0j4P5hLnPxzEugHYY+KahG9CHdSgjDh9kbCL59X4kD8e S5ug== X-Gm-Message-State: AOAM530qsAjqSXVNMpnzUaVEmPnzABUDSoHp3aenMnsnXjRzKAVHfQDA l4wz/I1Ea+lkXL0sbT3t2CvKebyr X-Google-Smtp-Source: ABdhPJwzvv/iS4L5Vg9p3VN+/Ly5dGg4dWZXNc6YwmQJfISVMf9Xy5QG2oWGTnXH52qpMPlUwiAs+g== X-Received: by 2002:adf:c6c5:: with SMTP id c5mr24699339wrh.13.1592174322990; Sun, 14 Jun 2020 15:38:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:42 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:39 +0200 Message-Id: <20200614223656.21338-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/26] avformat/jacosubdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/jacosubdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 121c86d659..3414eb3938 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) - return AVERROR(ENOMEM); + if (!sub) { + ret = AVERROR(ENOMEM); + goto fail; + } sub->pos = pos; merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n"); continue; From patchwork Sun Jun 14 22:36: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: 20361 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 30881449042 for ; Mon, 15 Jun 2020 01:38:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B27968B670; Mon, 15 Jun 2020 01:38:47 +0300 (EEST) 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 1F53468B5D0 for ; Mon, 15 Jun 2020 01:38:45 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id d128so12970666wmc.1 for ; Sun, 14 Jun 2020 15:38: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=1EtFVdzjOjOTYub/CS7S9hOGHZHE9OyLSjB6w13uuy8=; b=NYlYi0crNiz4g6fi5xL+0HEunxqJpXFrv9q0iS2PlRJJa6R+eG4YwFi0TlV2ow6Cmb 7xcV5rDIB61dfhj50pyuFKFu1v3ybf0Dfr5vBC+fWYdtNhP2bfX7VeXjQU+lMcGJ8SoG xFmsCl2zqGG7PGXquaJIory7TVLWrLm4uSp2FkwbNNcvGn1YhpTogLxZh+BUHOVWRmAk HY3yguBubjSUP9fDfYfcD2xkTK4fmafshvRbaPD1fUPf627/lQSHeVvjlNNX/n+CW453 qWvpTYuzixk3hoZ6g1ndPtfSX1AVfWLwFIBUbnki3sLlMmXiGKk3l3aSimkilDhtgBoI QJ2w== 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=1EtFVdzjOjOTYub/CS7S9hOGHZHE9OyLSjB6w13uuy8=; b=uFcdvac7sbleQx2hC3U4D/HlrOiKRe9uu9KeVhP4clXRoJG/H+0P0p2B7xw98QQDTH +yNp+JMPugswy0ny5gpGU6sylkCcSdvCZGe0TiJdZv8cfO5rZnTWHYDSswl0NuyCI5OH 0wxpEuVevtdpJtyWUceeaXoPD18m5VHGs8onEfYO8DX2eguLhKFaYPhB/W6q4Y+q5fuV VQGQ31K2QN7dpGD372AuVztv65/+PX/0yS52RuUUx+BXR1TtJ9SGLhHWDGKXvnw5vnoa zi10yctJP+l3E1dM9kCnbhGsd8a+VuUTzcZ8o1U3RErlQpWeSaHf93e5lnTBlyzMKHz2 12BQ== X-Gm-Message-State: AOAM5333Czs8RIf/cfOzl7haHFuGxxCy4HLIQtITyJkNE8a5rwtN585Q f4zJFqRglv0M9s4L3VOU96JxYwwo X-Google-Smtp-Source: ABdhPJxNAAGFWkWcaplnLxKT6TZ0ZqK/KhDKskf+Ml8coQbOcHZkOCPzX2qP+hB0Mb8hTQohLAwmgg== X-Received: by 2002:a1c:9d96:: with SMTP id g144mr9622142wme.126.1592174324258; Sun, 14 Jun 2020 15:38:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:40 +0200 Message-Id: <20200614223656.21338-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/26] avformat/lrcdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/lrcdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c index a9a117691a..46d5e2bc6a 100644 --- a/libavformat/lrcdec.c +++ b/libavformat/lrcdec.c @@ -202,6 +202,7 @@ static int lrc_read_header(AVFormatContext *s) sub = ff_subtitles_queue_insert(&lrc->q, line.str + ts_strlength, line.len - ts_strlength, 0); if(!sub) { + ff_subtitles_queue_clean(&lrc->q); return AVERROR(ENOMEM); } sub->pos = pos; From patchwork Sun Jun 14 22:36: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: 20363 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 2EADE449042 for ; Mon, 15 Jun 2020 01:38:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0818968B674; Mon, 15 Jun 2020 01:38:49 +0300 (EEST) 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 37E8668B5C9 for ; Mon, 15 Jun 2020 01:38:46 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id x6so15130032wrm.13 for ; Sun, 14 Jun 2020 15:38: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=H1pTitvXLUGqqzOdYsLtHrLOdLqwkdG7aWDii5zNctU=; b=dbRASpZRrw8jU0vzdVg1qojHi2sbsL2+modfdbq711rfMThNyvK7IObIZMjcVMa4uB L0eHQ23pFgreO/tmnuSQWZMSLqUudlkqsEsrrM4cXxbMvxlsMhTNN5Q2NZZSd6xHpYzb wig1Tk0budHW8UvAZCGlsL87QJYlvuUbE8X0h3XzeJomOGbtmJ3mk4vhQyif5OKMnWnw 46PyeJTmbP3BjAgAjIKtnB7CKexJDgEHoU0zZMLK6BFAxpSng3B5dDfOOd2YdVCugmce /yM+v6dUUAuAF/Q1/GTaZeET1toH22yTQEmq25yDWU7B7DVF8XDpN15vR4l+GhkAVr+M ZOqg== 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=H1pTitvXLUGqqzOdYsLtHrLOdLqwkdG7aWDii5zNctU=; b=KJpgsL9UehOMoYw+Kiu9sdg6YBWHqDMpUko6jI1wRHOCEt2/gQQMf+j9PlvgAOtetZ 2vYOy+TWiUOUKhUahjau4fmamIhQx1M5PiN24/bFh/RyLigwU6nqORU4puyjU7WPVVUL BMJEYTRPspgIWdqx0MRmqPgBDSNBiRTZww5qSF03gMiantQ4nmU+Vy7i5tYECkgUFxIb Kz/yOSLOvt4BsRYwNDesyg4burec4UGoi2BHYS5Uij30C4QkolKM56NALJmZ9iYTsD/J Il54GneQ9+YLiIDxFGXknhnK55s8xVMWPkwfXWjVFZgm2/5sBkVxwjABk8yJnZp/PScn sT0A== X-Gm-Message-State: AOAM532krxNtVllo7+Zqt0x/7boiYGvb6NsFV/RiR5luvYpZKoTMZZDq QQr2YJ68usyo/L4BW5bvB+ECbx/Z X-Google-Smtp-Source: ABdhPJyJONyBz8lbHFujTN6+Osr/vXj66A28UlRatnKjDPdPAU8ZL3CX/5XbG7REg22AKkPxCIXIkA== X-Received: by 2002:adf:ea11:: with SMTP id q17mr25306265wrm.75.1592174325318; Sun, 14 Jun 2020 15:38:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:41 +0200 Message-Id: <20200614223656.21338-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/26] avformat/microdvddec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle or when allocating extradata. Signed-off-by: Andreas Rheinhardt --- libavformat/microdvddec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c index 08e6fca09c..8759200f88 100644 --- a/libavformat/microdvddec.c +++ b/libavformat/microdvddec.c @@ -81,7 +81,7 @@ static int microdvd_read_header(AVFormatContext *s) AVRational pts_info = (AVRational){ 2997, 125 }; /* default: 23.976 fps */ MicroDVDContext *microdvd = s->priv_data; AVStream *st = avformat_new_stream(s, NULL); - int i = 0; + int i = 0, ret; char line_buf[MAX_LINESIZE]; int has_real_fps = 0; @@ -117,10 +117,10 @@ static int microdvd_read_header(AVFormatContext *s) continue; } if (!st->codecpar->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) { - int ret, size = strlen(line + 11); + int size = strlen(line + 11); ret = ff_alloc_extradata(st->codecpar, size); if (ret < 0) - return ret; + goto fail; memcpy(st->codecpar->extradata, line + 11, size); continue; } @@ -138,8 +138,10 @@ static int microdvd_read_header(AVFormatContext *s) if (!*p) continue; sub = ff_subtitles_queue_insert(µdvd->q, p, strlen(p), 0); - if (!sub) - return AVERROR(ENOMEM); + if (!sub) { + ret = AVERROR(ENOMEM); + goto fail; + } sub->pos = pos; sub->pts = get_pts(line); sub->duration = get_duration(line); @@ -156,6 +158,9 @@ static int microdvd_read_header(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_id = AV_CODEC_ID_MICRODVD; return 0; +fail: + ff_subtitles_queue_clean(µdvd->q); + return ret; } static int microdvd_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Sun Jun 14 22:36: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: 20364 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 063BC449042 for ; Mon, 15 Jun 2020 01:38:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E29C068B68B; Mon, 15 Jun 2020 01:38:49 +0300 (EEST) 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 E4D8E68B0EE for ; Mon, 15 Jun 2020 01:38:46 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id d128so12970727wmc.1 for ; Sun, 14 Jun 2020 15:38: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=vRSrj67wFsTSYqSHeApLP9WzWuGxgPCFv7tZHVWE6iM=; b=ihzNwtDv1A4e88cMug9kdK6j4kXwBkN7XES3p9fVI9V0DaLqPpMt9aHUufrGyDRgaY 6MOksPPCvOgkbJ/pBtqtfBCiUFxO1iCtgAsi9K7uzbnZO/VmkAY6MJqJuTemyNSPncgM OQH1DAH2PjD36tfktNZqz8DGYrcjI80JjGl5lMbKeu6bRiTMmBHZIESpyMbcVei8H8SF M2q5IEpRVEJy+4iIs1pqaYyE+3oE2HTMLxY1ArEIwaRKDEu4y2snvHQEjHV2bVfMbCbi nZhR8+o0GbwG5upQFUY0BeBEIUlGafRWrjN4aCq0L54RDU3NSTNZrarapl5+SDqKRpmH SAPw== 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=vRSrj67wFsTSYqSHeApLP9WzWuGxgPCFv7tZHVWE6iM=; b=F/7xYPrNpGI437SSS48imGTBxi2HY2IZKHO0FPo8UO60aM/pBsFscSuNiRaU6rNKRY tQDCPrsfNZcs+daxRngkqNM9CmGNAvbd2bwxT0aoEHejiX65cuAzkJNw4BvR88WkwHRv 6/ngprfzdOeTDrn4MUyDxbkuVkBJxDGrKNlLp6nGEfwpatAuWkbOcywdmqdSVuDpyjB+ Rv4tZCv6H2KLz07xSe/pwz4AZNebEkudS+CEocS6mJbUhh5kkK0anxINdsDO/SYmHpE/ 5Wem19qFfP0d3dateHS7ZVcLJ1Ef1CfQTSSp0pOlTh1sxPi/eqgMS7jSMs9dEMTAp3/0 Ez3w== X-Gm-Message-State: AOAM530sJztCgwHl+5knHJJgYf8HTr0GUq/5FcCmtrCRzM7ELPWiBbV2 rYBiexKvr0Hrbgn5MojSINnFp2KW X-Google-Smtp-Source: ABdhPJxtR+hEUEB4PzP9okigN7/VbvbI2jJPagIyWLaL6u4kIVUyc/eOfRk5wYRv4vFfdCVnJ0kHWg== X-Received: by 2002:a1c:66d5:: with SMTP id a204mr9871178wmc.134.1592174326201; Sun, 14 Jun 2020 15:38:46 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:45 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:42 +0200 Message-Id: <20200614223656.21338-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/26] avformat/mpl2dec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/mpl2dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c index ddee638c31..bea258d9e9 100644 --- a/libavformat/mpl2dec.c +++ b/libavformat/mpl2dec.c @@ -111,8 +111,10 @@ static int mpl2_read_header(AVFormatContext *s) AVPacket *sub; sub = ff_subtitles_queue_insert(&mpl2->q, p, strlen(p), 0); - if (!sub) + if (!sub) { + ff_subtitles_queue_clean(&mpl2->q); return AVERROR(ENOMEM); + } sub->pos = pos; sub->pts = pts_start; sub->duration = duration; From patchwork Sun Jun 14 22:36: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: 20365 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 EE9C7449042 for ; Mon, 15 Jun 2020 01:38:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D407668B503; Mon, 15 Jun 2020 01:38:56 +0300 (EEST) 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 1E73368B20F for ; Mon, 15 Jun 2020 01:38:55 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id j198so12856651wmj.0 for ; Sun, 14 Jun 2020 15:38:55 -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=RJwPUW5P9snf4NdVuTxUN1oweJjRhrCw77O1O6x5AYM=; b=gCDGYF81hED7KFB0VcfIUg3dggDdakriczCfSOAyFeEX+Z7rWGgFObPi7JZ/hsjVdj 0kJ6ku+WwjqXyKWMu6A3BPJkvOMg6PLMtSRKpt87rZSuZ9hwSBJrm//8tq57YKM0O942 sUEYpIuSe8F0++fjNJFS1Rb+FgyF9IzUmjwbet9IuIl4r92Qv5GD+WJs9j6Ogmsyix6a +nAtJ/WOrtC0ZxndJPIDaJ6XUp8VFgZ41Uj5egTVZBnv5V093JrkxHxvaW1kSqZgO9CC qyuOuq+iAgNVXmZE07uZQeP9ykWTudNFz9LC1wDquoFKVuVOzDMHRdeMB3XjHf0/fEG/ Ux7Q== 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=RJwPUW5P9snf4NdVuTxUN1oweJjRhrCw77O1O6x5AYM=; b=JYCYmF/+4OP2Onx/2flvYhTpXq72STPnvuXwZ7c0t/uKjH+jEI6Ev9znbYFKPfxelp OGHTD2diPpG0GqA2vjU1TWW0VE8/F7apBGSQIPvczMmuhS5HNYUILgIlvjKs3riBI1Mb utWgnvQyUz5PVKurKXqlOUzyVJF0+etx/tBK53zmsNIumR1thP2euH5CIO0IwFmVtTcs iViQPTFaBZ0M7n4JbMO+9K7BXeSK6czgMqTWmeqeZ18Z2RP/T6/Y8MTX7jIEcc9WQB3V byRqSAd/lapQ7gQQBbgmnmyNUQkECyti3p9/okjy1q/vKrEYdKbhmlMT2tVU6q66QC+d Gmaw== X-Gm-Message-State: AOAM533dOAYFeeEmk1/JPrRUy0nfxEj9CZe8qrum707AJksNTIBxcPq4 ZcO4w4bXkRz6d7hxxsZbuC8dCpEo X-Google-Smtp-Source: ABdhPJxJV9usOtMsxUtpET7OKDZJXFDy0AJLo3YrOToR/NXrVchJpskOatecnnwxeSd7Tyl0IMNGEg== X-Received: by 2002:a05:600c:645:: with SMTP id p5mr9752062wmm.156.1592174334333; Sun, 14 Jun 2020 15:38:54 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:53 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:43 +0200 Message-Id: <20200614223656.21338-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/26] avformat/mpsubdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon creating an AVStream. Signed-off-by: Andreas Rheinhardt --- libavformat/mpsubdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c index 82c73457ea..e7b83a1d85 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; From patchwork Sun Jun 14 22:36: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: 20399 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:80ca:0:0:0:0:0 with SMTP id c10csp2150307ybm; Sun, 14 Jun 2020 15:40:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwi+FJl15HQ8uSDIG4CN5GK9PjJ4DotaGO+Y7BWh/bxqQXsmKdwS3z4+PE0SEwDm9JsZlZ X-Received: by 2002:adf:82cf:: with SMTP id 73mr24585231wrc.382.1592174417858; Sun, 14 Jun 2020 15:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592174417; cv=none; d=google.com; s=arc-20160816; b=vXE8sZ4r9BYRgo6LMjLkzHzuKOtLHrbtfZ+JD5Srcvn5rhDot8AajNRGrKs/xoG1BN WJwdBKd6vMyJ90Qwxo60a0UCtp47K+yTtcExB56ElNyc9FzFqUSvsqJksZ2SHkaEe0U1 lQEGkLRGkg+E13ya+66VDSw6xuRH8OzHYuWRIKK5MlV66emPcKP6HNHPMmV7ncOHRaOg Gsn97bj+0aNHl/7WDwZYvFPtnX4KfN/JfUhHZ2HGC9Ma26qIReNRh1L2W8SAIkniX9CD WoXG3mD6iJ8Uzwi8cm2hSAfoE05xaLHLEVWrEwlWyV9TTDFGY3y1n7mXa576xGju4TYr 7Gdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=B4GTZ+dTKX+r0tiNUlmb/gQOvmkDY4aAgG6fJkmeGZk=; b=CDEmIZbQkr3MSrBgcUNAV6U5/FkyRzr3nXFzCNo01U/Dj+VlgTgXq1iLGPbfQdJaga ZfqNZ8/yHS0LDJe8bjH12mdz52VBFj8QhR/2JOADXIFajLFX2UplbSvydZGe73R92Nv4 0CGKVnr0uvFZ5vek69WmsE0k0H8qKLzQ8eL4vKPo3uFdmuTHVhOPLScE8G8kw/+HXVX+ QBN8iZjsXL1LSnTsvjtaw6sl9LrOi1XVjP0l72cDxdnK7WL5mjWrljwdt8FgQVr6Us5m hEVA9CQOqPjdjIz/rZGOfp2WbgFZbnUoRW4xabBC+AyUeDjnP6ps9/soRo/zG47EibR2 AlzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=IRnrUHrl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d7si13331815wrr.486.2020.06.14.15.40.17; Sun, 14 Jun 2020 15:40:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=IRnrUHrl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0D1368B655; Mon, 15 Jun 2020 01:39:12 +0300 (EEST) 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 0DB3E68B553 for ; Mon, 15 Jun 2020 01:39:11 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id j10so15164429wrw.8 for ; Sun, 14 Jun 2020 15:39:11 -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=4AR+qtR9nTLwdjudsFlNp42CBdqRIVyQMKH4Mz2JTh0=; b=IRnrUHrlyvZDZsNNT4Cd49Plf/tFWZRKnvrvFOuvv/ZFwKP6MbqCpw0cU+ufv+TU0R F5C8Xf0b5I+54/0KgPMSq9aw3K7ozUy/swbV5zohk9a9FFP3va1yzBwc67PGRIAgRGj6 /cZm/x2/5FfgjybRyeNmwel0fnS7wA3B+MrPLAR8N1f3C4ZYeZ2at4NHfUbjvhopKDJY 0HYr6hbppdKGFAHHbO2BdVkWg+v12ejKWPTmRCIZZTHxMRd5UfqD8Eu33Qq1Jm7DrY5W vjjUiRVL7wvX8MGrpJxBG4C5rGanMSCKzqNuzySJHYIN35pznQOx/P7X6XANxlvzjDMv QiBg== 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=4AR+qtR9nTLwdjudsFlNp42CBdqRIVyQMKH4Mz2JTh0=; b=jepTUJDe9VbaQdsDiAgCzbG3SPiwliDZGHwvNN6KH0WymNMjMVu6fQZCZ2w7easFJF t/Xnx9e3sKjQjGuH9dclD2IaJutyC3oJB41XlwSaqhBGHggH6KgUJSfy+njZMNn9uzIi J3MNhrv5hqFOnkS3ePUMD/lbtnpOWT/a0+NVNsSWat4Ou4hTndTqJhacrlhmzTtWj0Ds YUMQR9UqkUTCWe+CCMg8H8jpZh6eXZWXts0DwJWdTUo76ZHdJAXjvurZENiSNchgLB4t vT7GgbDdpU1ICUHrrax5uh05wPLSk7OLqpiLkpB5rWDS25VHRJxDA1WH4zQDVEUH6ytn Fk6g== X-Gm-Message-State: AOAM532R42w4Uy+KFfflNx0chN0Y7qQUYwqq7KfSANuJevFAWAm3CYE/ pMBN6lW52rLU28q1wB0N0L9YfjFX X-Received: by 2002:adf:f582:: with SMTP id f2mr27813993wro.204.1592174350226; Sun, 14 Jun 2020 15:39:10 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:09 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:44 +0200 Message-Id: <20200614223656.21338-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/26] avformat/pjsdec: Fix memleak 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" X-TUID: hofgjRDvff9X Content-Length: 1532 The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/pjsdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c index 8a5cc04f84..e30c23d830 100644 --- a/libavformat/pjsdec.c +++ b/libavformat/pjsdec.c @@ -94,8 +94,10 @@ static int pjs_read_header(AVFormatContext *s) p[strcspn(p, "\"")] = 0; sub = ff_subtitles_queue_insert(&pjs->q, p, strlen(p), 0); - if (!sub) + if (!sub) { + ff_subtitles_queue_clean(&pjs->q); return AVERROR(ENOMEM); + } sub->pos = pos; sub->pts = pts_start; sub->duration = duration; From patchwork Sun Jun 14 22:36: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: 20366 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 C61084491DC for ; Mon, 15 Jun 2020 01:39:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B057368B671; Mon, 15 Jun 2020 01:39:23 +0300 (EEST) 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 DF00468B581 for ; Mon, 15 Jun 2020 01:39:16 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id l11so15184243wru.0 for ; Sun, 14 Jun 2020 15:39:16 -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=mOLIenKdureWZsZKERHjJhmalwe77vor5dWL/kjs4Kc=; b=CY/fh5qLdBTXgsSN/N4413ofGVq4QppboReihFgIBcq06WGlW28ZquJEiDST9mlzgO 6QL9ZQm2A7AWwhThNoTEBEi4qtRaVz72vJs7PRxjuVKnwzCuBnXp1XOtIzckbdDseSj1 I0laf1wQtT7u6Ifa7Y7nPCimQiOj4qXm/rxItm0HANYFSXTcXCgVAxKHJIGAxM5Cc/lb 6rPDOQ8jB8DwI2yqBxLRA/SYiOLkKV6tOqwJeFwjcwqEQs24KuEyfcReVWEIqphQwpPU A+RC+rPzZhznUz0gf9KItls9CGK8TDdgeyFVgfoX7UpesvKQN6egRKtXSgIHWhmtOveX DeWA== 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=mOLIenKdureWZsZKERHjJhmalwe77vor5dWL/kjs4Kc=; b=W9A+tXn5Ui/Q7ARo8cq7pzEGIDHxkST9UwAWO9E3dv/3pIRQtWbmivQ9mTkntUXFYJ 4bZYk+660mSsqBVVeHEMDxJR27CW3SiznJSZVSDGNUUjuYHZMI54Zk1XtxOq0QJ4GvoK JCm5gqsZva9/xNwZhltEqJ95ky/NXg7K7mqT247DodVjQ/vi3c2NDN4Yk3gB13Y3islq pqGY+TjWeGHW7B/gFz8VKg4b0YPBGOltkWwjOywfoVsLUzoF0X2YGz9v9huu+OWmVvXR dCRtIzmcTTt1EKgd7D/hXhOh1Jwh0PE5h3ZMMYKAboepseNo++kgM7UfrnDw/c6mmWsn LVjg== X-Gm-Message-State: AOAM533hqA2JZKg8wbwMQvsQReVvi04c6JkkZBWZJYDWfcudji6jNT94 fe5zYYnAp8T6wEqqOmssmbQ6HlRP X-Google-Smtp-Source: ABdhPJxP/ZH9cph4mBYETcpOAnr5Xo0ihPdbvYnhhK4oKKX0BD0fyn07i2fFC8tJB2XLqq/sZ2HcuQ== X-Received: by 2002:a5d:6305:: with SMTP id i5mr25127440wru.268.1592174356053; Sun, 14 Jun 2020 15:39:16 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:15 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:45 +0200 Message-Id: <20200614223656.21338-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/26] avformat/samidec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle or when creating extradata. Signed-off-by: Andreas Rheinhardt --- libavformat/samidec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/samidec.c b/libavformat/samidec.c index fd98393086..3070ef9bac 100644 --- a/libavformat/samidec.c +++ b/libavformat/samidec.c @@ -108,6 +108,8 @@ static int sami_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &sami->q); end: + if (res < 0) + ff_subtitles_queue_clean(&sami->q); av_bprint_finalize(&buf, NULL); return res; } From patchwork Sun Jun 14 22:36: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: 20367 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 BF3D04491DC for ; Mon, 15 Jun 2020 01:39:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F50968B5D0; Mon, 15 Jun 2020 01:39:25 +0300 (EEST) 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 D40A868B677 for ; Mon, 15 Jun 2020 01:39:19 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id f185so12964779wmf.3 for ; Sun, 14 Jun 2020 15:39:19 -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=su0zVV4NZYs4wqYbTir9NuxYkNr2HvQmwE1o3tKWAgg=; b=rkj1SOjbP9RNIPwyo/K/WD5u3Xf/XgYC0WZmlyYgKHSV7KMz6+hcFDgQEWi3Zefmyd 4vaTojdurD/hGEHmWHaioH6LTZTEoPsIWWf9F5JDg71i9axvmxFhZI5x1fbNFc0zptZt tuziaB18NQ8hafchGpLhceNOOKn2I632AKaQTisYUStKy8aNjW4AvICKbZatdM0SAEc2 5XbEI1vSFGTO2Brbm5Up+j1L4jAAin+0byT4kVhj8bzK+3depAUob/j95vT76m1JRxRP Fwd6M1HJC7+zm8dpmSOSCLUZhRrKmzINdwk3ZnDXuiR9mi+2qWazDzDHxeS8f44nmWlZ zixg== 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=su0zVV4NZYs4wqYbTir9NuxYkNr2HvQmwE1o3tKWAgg=; b=T8nJnShoPjpa8bKNlXTo0bO3JClZkTjqDxTILUcCUmDgdReIF0QCHUYgKqGefeX58L qc/p48uN1H9npDbGX3OR4swu6MPj9fEAxhQt5dHdp9igFBRGB+BtvzeeVhVZgcBvX4pt k8+26R/TaU8Cl6DX/jjyuHHJKOx7w9b0p1ChB+INgHgrebp9Eo7eKlKnm03VKBs1HaRV XPCsS40zFdEcaIRSqiJZDe2mtzxpuzmcmDIrDjJeAga29mvxwubUP7Ufh7BHIVXjNXzh ZKeP5+taxdtwz5vgwmklbWA9KptGYMylMFmSBAdhOA0hdf8lbxtwp6E9mahqd3j86Eqy giqA== X-Gm-Message-State: AOAM532vRc/F9OK/GTmg7WSUUy6P66YbylS0/lWEK2anHpD5XcOTwoMR zR7yRxXQmquL6OGPTylFpnI5xR2k X-Google-Smtp-Source: ABdhPJxYiycAw9shHizCWXGAdBBH/MN/a7myUMhZCl2HPs6WxzeFAd+TomM789T0DhT31DQsRwPCbw== X-Received: by 2002:a7b:cc08:: with SMTP id f8mr10502927wmh.106.1592174358964; Sun, 14 Jun 2020 15:39:18 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:46 +0200 Message-Id: <20200614223656.21338-16-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/26] avformat/sccdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/sccdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c index 0eb1dd307e..72f47f70de 100644 --- a/libavformat/sccdec.c +++ b/libavformat/sccdec.c @@ -144,7 +144,7 @@ try_again: sub = ff_subtitles_queue_insert(&scc->q, out, i, 0); if (!sub) - return AVERROR(ENOMEM); + goto fail; current_pos += i; sub->pos = current_pos; @@ -159,7 +159,7 @@ try_again: sub = ff_subtitles_queue_insert(&scc->q, out, i, 0); if (!sub) - return AVERROR(ENOMEM); + goto fail; sub->pos = current_pos; sub->pts = ts_start; @@ -178,6 +178,9 @@ try_again: ff_subtitles_queue_finalize(s, &scc->q); return ret; +fail: + ff_subtitles_queue_clean(&scc->q); + return AVERROR(ENOMEM); } static int scc_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Sun Jun 14 22:36: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: 20368 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 E5C234491DC for ; Mon, 15 Jun 2020 01:39:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C381168B6BC; Mon, 15 Jun 2020 01:39:26 +0300 (EEST) 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 C5AD168B6B1 for ; Mon, 15 Jun 2020 01:39:20 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id l11so15184314wru.0 for ; Sun, 14 Jun 2020 15:39:20 -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=HYveE5xltcOBDGCVS7AAgA70mWegeASOgTJ0EXgFLd8=; b=mMDHJytksOcaVDZc8qsITYhYMix/mIv5I++qRxUlbQT4WFPe0uZF51NGsyVdS0Mq87 ciimReNZJymCCWgEvY1FdwAEbEFJHxo7S7hAGsQvGXlplduD2LsHJfdnc3BLD9hp8EMl xShAb4eqGgJwud78FE7rZ9OepuCStj44w3u7Hg1ZD7EJY/Fr4CtBqnaRU2+XyHe3Bm5S UKxcMAtgzQSTQ3v8Ckf/2rDuv/JF9X4qgez4KmoqdkjbHkkN07VouMhcNLiHtR/+UG9l 8uGYORiA3PMSy2Hobs0efDD19STis2xtrxhRU7GTitaPjvdXUT8CZp0gocHaAlOdfQSZ zavQ== 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=HYveE5xltcOBDGCVS7AAgA70mWegeASOgTJ0EXgFLd8=; b=RXLeHyUj7mTjRATrY17/t2/Hnm3DSv+Gw46a4PoaSYeT4r7MfRywTleINXRyGFDJeS LGb9d7CzpbHNUhNeinWdkusiz8o8lqRn3S56dkNkWWKRCATl7gjtt96o1g3qYfJzoyN0 3zfWEUvx8/wr68glkyUlCKagy5Wq7Gf7qOXrrk0vHs/C3xli/oJ6YB17D0aLb4+N2CmL f2q+8A16S3Bfecj8nGdyINj/m/s+Tr48jSbxK/bD3pMUDuwhwLEqahVJLHKiaNNUDo3x qQGPW5Q/lHL2Ax1zejyirb1t01Nay0UcgirfjsyaEQ0XUG+OYQoj4tFY2T4DM4JWc42I 4y5Q== X-Gm-Message-State: AOAM5319+DL5VWC2HeJs47SBUHPDc3t4nmAv9Oa6+SAquBNUkPeN7rrK Yv/o0avMSGYzhYQjUtF+/Bk11rFA X-Google-Smtp-Source: ABdhPJycPUkVhGF3k1C30IbzDgRxC5C7oWL7SMZAJ5UQ3yp9VukvV/zQYc0I6vff/lY5nZb+12GiLQ== X-Received: by 2002:adf:f84d:: with SMTP id d13mr24044644wrq.99.1592174360060; Sun, 14 Jun 2020 15:39:20 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:19 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:47 +0200 Message-Id: <20200614223656.21338-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/26] avformat/srtdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/srtdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index 40d324b44d..d6ff00ba6d 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -207,6 +207,8 @@ static int srt_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &srt->q); end: + if (res < 0) + ff_subtitles_queue_clean(&srt->q); av_bprint_finalize(&buf, NULL); return res; } From patchwork Sun Jun 14 22:36: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: 20369 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 EDA444491DC for ; Mon, 15 Jun 2020 01:39:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D983F68B6C3; Mon, 15 Jun 2020 01:39:29 +0300 (EEST) 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 D0F6D68B6C2 for ; Mon, 15 Jun 2020 01:39:21 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id x6so15130650wrm.13 for ; Sun, 14 Jun 2020 15:39:21 -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=E2MGWG4NsPkI2FXsfgw6OstKnJIH/2DAM9XHVBkA4g0=; b=LjUrHb7Zljmr/7Sr24cz4CVyFABfRvQmdh9sbKKIqFqdBTiFTcc2NBf5n1L3sddeQT T+DyGJkZJpN+rc21qh0H96CMvBxGAmev4e/oLWkU3Q5cwcumOvxviEmgDUYq7sxhttyE 5Y1H5Ypk88HO7NyKjMzm2p76WyumSmEI4r9HK56wfxjRyC2M9HhwiZ55Yh3dYhoakhj8 7x1Z6fr19EjynpwL9CLDkhKGMBptqMH8QrzGL0JJBgjHuQIj9m2Pl0E4tG6llO9Hx0HW nDREBP7terz3UwPc6qwWhUgHtjJFmAFq61FkRzaiDKGI+7AfW4aSxTN2oLolN1QrbIii yTOQ== 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=E2MGWG4NsPkI2FXsfgw6OstKnJIH/2DAM9XHVBkA4g0=; b=LEyiW+HaOAUy4kQrm/VvF2vbIUi1ksI6UZJaRfaeMG7GLCkhNrUM6/q9EzIbIzSDXE u7teNd+/61gaJhmr3z3vc0Q5hRBuBtWYCxKTk/WebA1kewJr5hGZM3UzCdzBUCJ6jddu GyHkWPG20/gMzWJmC+g7j6IxhRoAUsHJGxE79t+oCLEMl52QbTbawV9Aat0qZMXPNSk0 2ae7PA4Z3TPrqigBkAky73ls5e3liEDyYCvl39vEEjJLgoIHlxILqwjeUcmj4PKCpec1 8+FZzMdo72dVr+eFEp1TuY4kzOm5DVJFDQXCXUzfGRbGWXRBQoeR5ZRtVI4HSIRGyRf4 7miA== X-Gm-Message-State: AOAM530ZlXzbu8TuvBAPSrXf0mDG8xyIy4EQv9kD2VD5vYSuOtCUlYrj yPhsgw4AmQIR9dvB88ncKVlqCH4q X-Google-Smtp-Source: ABdhPJx1qhCkNtePP8MAQU96yNY2p2LsgYCwtEV2KDnMrKpraALGuNkzGXVDhkxkol0M1CGCx0111Q== X-Received: by 2002:a5d:4dc9:: with SMTP id f9mr25192800wru.407.1592174361080; Sun, 14 Jun 2020 15:39:21 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:48 +0200 Message-Id: <20200614223656.21338-18-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/26] avformat/stldec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/stldec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/stldec.c b/libavformat/stldec.c index d6e0713f8c..fb67407ac5 100644 --- a/libavformat/stldec.c +++ b/libavformat/stldec.c @@ -97,8 +97,10 @@ static int stl_read_header(AVFormatContext *s) if (pts_start != AV_NOPTS_VALUE) { AVPacket *sub; sub = ff_subtitles_queue_insert(&stl->q, p, strlen(p), 0); - if (!sub) + if (!sub) { + ff_subtitles_queue_clean(&stl->q); return AVERROR(ENOMEM); + } sub->pos = pos; sub->pts = pts_start; sub->duration = duration; From patchwork Sun Jun 14 22:36: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: 20370 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 1FEE14491DC for ; Mon, 15 Jun 2020 01:39:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08B5468B5BF; Mon, 15 Jun 2020 01:39:45 +0300 (EEST) 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 581AC68B129 for ; Mon, 15 Jun 2020 01:39:43 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id l17so12813118wmj.0 for ; Sun, 14 Jun 2020 15:39: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=cpfKrVcD8NgWPBoK0FA9rnqN7oH4YH+n93tKDxliV+Y=; b=FaHJj4UNIQHM9q68Ol5Lx1gSy+8LiydKtznHwWQB7/ieA58tv4BteCQjycrUNjINat J0tmZyedbIxQNoGo2EAaE6HhFNxVeWxV5ffk84jqpojwYF4p2LUbZ2kjAexAgTwQ7Z4K Ce0rIT3M4PTK+HS0QND7Wc6rPAoYBptGfnjMNhddqN+a/cYudZ0C7UQayN2nzXtXBkIY PxhWMeNp1DK1aQQcm37G8TSA4NvCH1Q5mwcLaFKaIJLC3V86WlxTsKHMKPW01J3MJDxo ehVMdxdF61XExxTkaWfCIS2gwGwfX4kCBQ4srQLEeRTJeDtPuBEWI8cJzMtnknD0bKnE AyYQ== 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=cpfKrVcD8NgWPBoK0FA9rnqN7oH4YH+n93tKDxliV+Y=; b=WTpbUBI9SFOjFedRV6TJqs7lM1PF+NFtllK+yd8yEJst5qlNGuopwrmr9aibr4PsbW 9Y4H2xA3LMKfYnyYxYYBdVegsMzUJVHD6CarVeCIX7FTYC35W4qHN2gfRofcNpgVds/r 9HFo6gKt8VlitFt8vu1uyTPQG240L8N7gwmhuLWcINoaQiu293H8g4WV5G6UWIYU+pMo Kgxx5kkJ1RdWKDpvVWZSva1lMEU1v9+GH0+3DJxy/RFtjNI2aXYg7X2TNKYjDu/PhJw3 SLXPjO1ReHPQ3YBO95i68spIMHMtYTcWUyoIKXfshB9segTwevLQUfeCt6yPT4O7xIpB sVUA== X-Gm-Message-State: AOAM530ZtIsiGH+dMDodJMPgf0hUZSGTL4OEvxaqysw6VNlGg1XEuyH0 easLd3Cf2q7fyX1k0M1I+4m/RmaB X-Google-Smtp-Source: ABdhPJxQN/6FxA7ATp7D7aGRY04zJ0ydwWMz97nP7rb+jTde7TNCBWB3Zwkg2tlwg5HvTiTkqvptfw== X-Received: by 2002:a1c:c302:: with SMTP id t2mr9686606wmf.72.1592174382379; Sun, 14 Jun 2020 15:39:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:49 +0200 Message-Id: <20200614223656.21338-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/26] avformat/subviewer1dec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/subviewer1dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/subviewer1dec.c b/libavformat/subviewer1dec.c index 1360d9b7d9..f2eee294a1 100644 --- a/libavformat/subviewer1dec.c +++ b/libavformat/subviewer1dec.c @@ -77,8 +77,10 @@ static int subviewer1_read_header(AVFormatContext *s) sub->duration = pts_start - sub->pts; } else { sub = ff_subtitles_queue_insert(&subviewer1->q, line, len, 0); - if (!sub) + if (!sub) { + ff_subtitles_queue_clean(&subviewer1->q); return AVERROR(ENOMEM); + } sub->pos = pos; sub->pts = pts_start; sub->duration = -1; From patchwork Sun Jun 14 22:36: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: 20371 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 250224491DC for ; Mon, 15 Jun 2020 01:39:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1016F68B641; Mon, 15 Jun 2020 01:39:58 +0300 (EEST) 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 4DCA468B129 for ; Mon, 15 Jun 2020 01:39:56 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id l17so12813307wmj.0 for ; Sun, 14 Jun 2020 15:39:56 -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=7GDYjIBiiq5ZB5R9lCcsqddu7IQq/adf+NchiKdwfDI=; b=g/QHi5ILkkcwcnz3JkVsGzLT9OP3lshsOOoSdlmciSNalNd1ZT7ixcZvamph3dwv0t cx1o6HoZ+zbcB9FJmp5gJ+z7FI2CzjRo2khX/CQOLroI7MmZ8aE7pWwlsByOAzDDa/yL +dDR8F3q6hZjzKCBdwrd26PZDTK1R+ICJUPBD7tZulWWmiT5xuheLGynwFLwx6YerrL1 KMIFesWPSLrZ5ggUuKtz4UMvkUJ4/DUj/pHc70/DnnndPBPwxGlMpxRA7On5JgVz24r8 GHjUVR086LaSNWePnkMWqL58kJEYhBfG/e/15Kf63vTJqr2fOf3mYQbonXKfP/ps2LL+ 8X2A== 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=7GDYjIBiiq5ZB5R9lCcsqddu7IQq/adf+NchiKdwfDI=; b=LeTQEkyUFBRk5U3/iW3g1eoc6njVtKNgYt4ToF9/15s78i8I4Tol2kcobWR/FPUJ9J QZz+UU69fe/wHz8dgry5CwlkPqnL6xqNrGlkzpDMuuyIQIJ9aBj36d6hXlkNXdwzVCc7 kzkHmCqKqPPtD0ZFcC5lmlvIzruBD/A58cVO4lD7hUghJy/MrTVjVHxqnT7jv1aKmIi+ ZYQylmSZnEcA0FQ8jEObyDsws+/RiUI6j7OvxIvZiBRLfeblAZcmTg8M3Y5ZB26hILSt JNGOPsnwZM/WcGgdiBobR1PfVEeLWXZkAXjkw5lLZvFVOl1k9bNJkOpaCwcgfJOgNFOB OXMQ== X-Gm-Message-State: AOAM531pj23PV+h9yI3ueMWBeGtNpMkovtAbbmflcDlNQHkRc4rRzOBf fIJFh5S32bxcYYR35D+DXqiytKAQ X-Google-Smtp-Source: ABdhPJwvxyH6NrePpJGsMRXXv3+MWxKUEZAnaHcXWalBlqL3ZCP3BCf3HnldP/vP4MSqpLM0BYQBeA== X-Received: by 2002:a1c:b443:: with SMTP id d64mr9534578wmf.157.1592174395450; Sun, 14 Jun 2020 15:39:55 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:39:54 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:50 +0200 Message-Id: <20200614223656.21338-20-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/26] avformat/subviewerdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/subviewerdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c index 83378eab5f..fdca3a4820 100644 --- a/libavformat/subviewerdec.c +++ b/libavformat/subviewerdec.c @@ -172,6 +172,8 @@ static int subviewer_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &subviewer->q); end: + if (res < 0) + ff_subtitles_queue_clean(&subviewer->q); av_bprint_finalize(&header, NULL); return res; } From patchwork Sun Jun 14 22:36: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: 20372 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 096AE44A382 for ; Mon, 15 Jun 2020 01:40:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E76D868B6DA; Mon, 15 Jun 2020 01:40:14 +0300 (EEST) 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 89C1F68B6D9 for ; Mon, 15 Jun 2020 01:40:13 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id g10so12779375wmh.4 for ; Sun, 14 Jun 2020 15:40:13 -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=aD7Z0UpOr4n+nxnFmS+W6eh8QJRRSvKHnb7sL/+oGGo=; b=cNk5pvlx7qQ6chij4YFySbrNwXx0s2asJIOco9qoocNb46GE4QmLTnmwqiUag7hq/Y daS7AeMECbH3odscevW/lh1fE5WvP+/Frr9x/mJP+glUqGLWZyK3zLmyesf8D1ygIHG9 gMW+cGibMF9cK7HWygBN9eltmlHe4hg/L67VxqcVJDaHEW9PYqOu577srunWeaIk5KBO PWI6uSza8KhSfAAvD3nrlkAVadXTXTHJ1j/eOvJnqlBvqJ6a/ASfVvKah8aIjqFwxVW7 knMrVSG22U+mY8Mty2rgaT0IJYY8FKFP6FM2b74m3PFjIOc17D3LnlXAtdqsOFMFVy9N V1Lg== 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=aD7Z0UpOr4n+nxnFmS+W6eh8QJRRSvKHnb7sL/+oGGo=; b=c+jhDw1lSH2iTj45ihYk4mabP+/cAIcleRk/bJj9qCCfBEJ53nIdVzFw+9Z6f2TjqM 4EDkUq+4CaNTlxrsa3QdXGudY4oG24C76EB9qYhXJyrBM8CnxdLTE5zeIp9wc9mQL50H NsrhZRwMqEehXZvSfv2STUokrHApN3bFHsTNFk8HvPrdKRSKFWKIwIcnY8VbYIeJtCUd plIWzRKLCZseCI5aX85ytXLe7wHlcZdRWCh6vwPDNSncQZWr8qk/oxhLBs8xL0swrROG QZUo5s7rLfUxjm/6IVWvo8NvoacAsANo2K99NltgGpo9WSao0kiHZCzT254tc4WzUWPl Lihg== X-Gm-Message-State: AOAM5300nf4fe2zPzFBatVats5fUTEnXttWu5JKS+88OKWJ0QG68SROT iGY6ZpdfWeh3nxfIF0cTwYifPdJz X-Google-Smtp-Source: ABdhPJxqm8wVVmixYH/xegKLmmK17HTdTV2yHQ8ABU+0/ZDBh9E/4lm/I9aUk4kb6Cioqj9QiKcu1g== X-Received: by 2002:a7b:c043:: with SMTP id u3mr10549422wmc.185.1592174412781; Sun, 14 Jun 2020 15:40:12 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:40:12 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:51 +0200 Message-Id: <20200614223656.21338-21-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/26] avformat/tedcaptionsdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if allocating the AVStream for the subtitles fails. Signed-off-by: Andreas Rheinhardt --- libavformat/tedcaptionsdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c index 5572bfd931..3255819e77 100644 --- a/libavformat/tedcaptionsdec.c +++ b/libavformat/tedcaptionsdec.c @@ -275,10 +275,13 @@ static int parse_file(AVIOContext *pb, FFDemuxSubtitlesQueue *subs) static av_cold int tedcaptions_read_header(AVFormatContext *avf) { TEDCaptionsDemuxer *tc = avf->priv_data; - AVStream *st; + AVStream *st = avformat_new_stream(avf, NULL); int ret, i; AVPacket *last; + if (!st) + return AVERROR(ENOMEM); + ret = parse_file(avf->pb, &tc->subs); if (ret < 0) { if (ret == AVERROR_INVALIDDATA) @@ -292,9 +295,6 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf) tc->subs.subs[i].pts += tc->start_time; last = &tc->subs.subs[tc->subs.nb_subs - 1]; - st = avformat_new_stream(avf, NULL); - if (!st) - return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_id = AV_CODEC_ID_TEXT; avpriv_set_pts_info(st, 64, 1, 1000); From patchwork Sun Jun 14 22:36: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: 20373 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 D39F244A382 for ; Mon, 15 Jun 2020 01:40:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BB13268B6C0; Mon, 15 Jun 2020 01:40:43 +0300 (EEST) 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 8F42E68B654 for ; Mon, 15 Jun 2020 01:40:37 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id h5so15198671wrc.7 for ; Sun, 14 Jun 2020 15:40: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=06V2Gqz5iB6VxwwHEiExfADC+0GOBdwwX7x4he8h+BI=; b=M/rzkMpEfaR8MjFHmTWazgh+RL8ig0Atz0cxxg/TBv7+E9NmoHYhEOs+PbBAIwgsaM YWKGK3PGMP40+ZquNOSM5QCEMlXnybeCWamwiJBgpwWf/ZFgSEhX4MiycPq6zYTh6CGM foF5MsulBEQvaKURqja1AlZ80AV89+ZSiW6lnGKSYAaPP4uD4rihdOZ8BOAOlc9NFY21 AAskP2niRgk/oHgP8CvEBnXrl28bbFFOJWAiEqyfCmk7jQCFCNNdbUqeOeXOo37+y8bf YzoO3yQVuCuA2Hl6YC5/Dw8CCwZwTvGmXn35/jSBhhbEOfjpWD8g49rtr4AkxMBBYw4d 6sYg== 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=06V2Gqz5iB6VxwwHEiExfADC+0GOBdwwX7x4he8h+BI=; b=PZQn7Q7s5LLL5iOIa6X+gUXAZJDfNbCoMMNmFYK1EZef931yn+5QP/1OLmZS26HTfc AQjMaG+EPE9+jabwMniZR9RvoXlpKFlc0zwe/FAGhlCU3WP800CNnm/5YlRa4IDE4BJp Ts/jbX1K3lnB4+Jm/LmdoNenXQelzV4TOeJE3HcX6wQ5ibaucqPyPGwCkazrK8U4Xecn fmlGPwJ/0ItPrGG/0lgsSpT8t6qe/RYHeX6FdWHJGrCfw39EebOhWdW9gDyeesTMKGvQ Ni/543jpyGP94VevYMlGTcEUyvFD6ZLzaVzTH905G/tLrAkHQpmRWfeL6amZXeq/b92P Xc1w== X-Gm-Message-State: AOAM533i3Mv+ldnFbYVefTTibZ2MNYze9CUX0Try4fRfIGvE+Om5TRp7 H/Uio6KInmdqNVfsHcWrTSrH5xH8 X-Google-Smtp-Source: ABdhPJxL3yoO0cxHFGhevFiNqd8c4yhBf93VfiztU3eKlQFcKdOCohfmPmkir3sMi7tqGTrcacspKA== X-Received: by 2002:a5d:6144:: with SMTP id y4mr26659766wrt.185.1592174436824; Sun, 14 Jun 2020 15:40:36 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.40.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:40:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:52 +0200 Message-Id: <20200614223656.21338-22-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/26] avformat/vplayerdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/vplayerdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c index e3e7b4efb8..ca23ec76ac 100644 --- a/libavformat/vplayerdec.c +++ b/libavformat/vplayerdec.c @@ -83,8 +83,10 @@ static int vplayer_read_header(AVFormatContext *s) AVPacket *sub; sub = ff_subtitles_queue_insert(&vplayer->q, p, strlen(p), 0); - if (!sub) + if (!sub) { + ff_subtitles_queue_clean(&vplayer->q); return AVERROR(ENOMEM); + } sub->pos = pos; sub->pts = pts_start; sub->duration = -1; From patchwork Sun Jun 14 22:36: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: 20374 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 F19A644A534 for ; Mon, 15 Jun 2020 01:41:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DB39568B6F2; Mon, 15 Jun 2020 01:41:15 +0300 (EEST) 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 EF3BF68B68B for ; Mon, 15 Jun 2020 01:41:09 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id j10so15166492wrw.8 for ; Sun, 14 Jun 2020 15:41: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=EmZCwcV0Ai9E6ot03Kkc8KtT3aWTU2k6+1kVHlpdrsA=; b=I/Y/D1/7Iz3ITq9/OjSLiCjXqxXEes10ykOJXf7ELfaDNxwzyPCD4SU2ZFpGMQcEi3 vdIGsyH7iyErBD+MTYgKgxILOoqnk0vfpfqWlfZhwMCUWj3Eg7i1s3Zmmlt8EyYzEMl2 GycjFPCDaTzzco4NU/uHuRdldpR0MYprbTszwzaW8j9WsyFKwjl9pEEA3utIrt03cuHX KK8TDD8XIm6cXFdJGoDcS1skCl5k3jlpJyWsBUfpc4/8yZ1M2DIBVVFlnJP8LE/BEJun yMGOu7kbN3gUqsPtqsgMNPV73PabTX8upPSRCc0x13x/HGv2GDTkbfTUIyD1IW/gf4tV t2Cg== 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=EmZCwcV0Ai9E6ot03Kkc8KtT3aWTU2k6+1kVHlpdrsA=; b=bryTPcwtkl/Xxlz021hC71rHamSU/wXOOaZsslJcZB+qjtsfi02Lcx3jjFwU3aa2Cr UO4S0m/wexF60JzJfunlFXzIxk7YhtSjPFLKCSIhrfk8PZ7VyY0WdTnCb6Lx64xEKoFo 7UQyTazFbJtX5OfJrusslU+WmRycGRaAIJwE834IyD1Zs54vA9cv/9eGdtKLFlh7gmO9 kk3pFR4HTmnIftlbmjAsgXtACWg59iZhU4Ks19ioVhUmCvDjSr646ZM6rE66QVVdvLaL HbEr1h8lDPmwawfaKpQpNS7ATNr4dyxEvOIxdzWT2kkz4rEhpsK0syepp1gnfGCwGHsY Hjtw== X-Gm-Message-State: AOAM532ScruN55FTU48kueH9DCJ0wdyVmfDcAcw//scmSXb+n0W7yZPv JHi1JU0oZiG6HrQ/Fgar7Q0fE4i5 X-Google-Smtp-Source: ABdhPJyynkwHY4i4+JYOOPmgp4sWIFkevgVCaWUsJ66T6Xk49z2BEnymjvjQuIgGD4xJHYuAMIq5Mw== X-Received: by 2002:adf:9544:: with SMTP id 62mr24871134wrs.32.1592174469106; Sun, 14 Jun 2020 15:41:09 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:41:08 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:53 +0200 Message-Id: <20200614223656.21338-23-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/26] avformat/webvttdec: Fix memleak 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" The already parsed subtitles (contained in an FFDemuxSubtitlesQueue) would leak if an error happened upon reading a subsequent subtitle. Signed-off-by: Andreas Rheinhardt --- libavformat/webvttdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c index 6c4d5f6736..bd3d45b382 100644 --- a/libavformat/webvttdec.c +++ b/libavformat/webvttdec.c @@ -164,6 +164,8 @@ static int webvtt_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &webvtt->q); end: + if (res < 0) + ff_subtitles_queue_clean(&webvtt->q); av_bprint_finalize(&cue, NULL); return res; } From patchwork Sun Jun 14 22:36: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: 20375 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 2B8EF44A534 for ; Mon, 15 Jun 2020 01:41:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13BFA68B6D9; Mon, 15 Jun 2020 01:41:47 +0300 (EEST) 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 2C0D468B6B1 for ; Mon, 15 Jun 2020 01:41:46 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id h5so15199876wrc.7 for ; Sun, 14 Jun 2020 15:41: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=EYGKTczlP7Z0IDClhcpkGtDAbcfsh4apH5mSW/wDmSk=; b=ldXBeYAokhW6+4A1pztU+i3wQsPwV79aaT3jnOYYeRGTKlGewcnbagIdfCwiQNHd1s NIM3W0ZtaU6KnZPVnmKGg/4PCxjqQu8H8JfAhxHds20flPfZ1ELKDmA8BrAecalSaSOD x71QHAWGUYKibzkxLoCpjlpR3aj8vgkhjELY6dGIiw+5w0sGSgiCZoJvZjlVxTDbiS6W tS1iZvJG9ANDtPPgZqRQVdeWAlPWPbx2vsjHg41SHXVSOSS4lILMu3vVEA1BdFmT/2TU KP8/h8z3TBkYtF+HEOu2eFklZhSLTJx94dRbPTxfF2nR8ZH+Yn7yQ6WtXDHThqZNm9Ti aK9g== 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=EYGKTczlP7Z0IDClhcpkGtDAbcfsh4apH5mSW/wDmSk=; b=RIRWstumF6bnCJvtfvT2T87rJsXZIE3awQ6kiLADqUFiPJ/mQcvu36aXWTz9yjYrxf vlPz907bvTCOO1O1q9ySM6m56IBLRTjURBImUp67eveOsDl3374qQqtSbus2SX1zzq1X fuTurYXyCgntqHRoAi99UeBmr3QZOFwjb5aKxj+sI8lIZk+ah2fY82TuJjxQIdK/oCuu 7+wP0U4lNnyBlXwgJeQehGEADF9Lv5YOiRmcMudk+7moSyOrmdt50FWk9CNTBQ/JFBno u/vbbu/4IUXwJCW36KeBmRV6/N9/UNpP4hi4WuYLrYGEjD1iCLDuTNHAiankK+l3Hv4A GY4A== X-Gm-Message-State: AOAM533nCnTRyrft+avQDvz2rFiOkood4R4hz0uErLv+sMdFfuKZwg06 GoilwNTDS7EL2trxvs1coERqNU5P X-Google-Smtp-Source: ABdhPJyyL0ZYMzgKySOu2v+dn51tj0u8pWncfvoSpSQ/a+IDPq8vS6RCd4N4XO1o6YER8AgYkqdlDg== X-Received: by 2002:a5d:6884:: with SMTP id h4mr27755709wru.198.1592174505366; Sun, 14 Jun 2020 15:41:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:41:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:54 +0200 Message-Id: <20200614223656.21338-24-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/26] avformat/matroskaenc: Don't use NULL for %s format string 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 argument pertaining to a printf %s conversion specifier must not be NULL, even if the precision (i.e. the number of characters to write) is zero. If it is NULL, it is undefined behaviour. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 1c1ea71f59..eaed02bc92 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2118,17 +2118,19 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac mkv_track *track = &mkv->tracks[pkt->stream_index]; ebml_master blockgroup; int id_size, settings_size, size; - uint8_t *id, *settings; + const char *id, *settings; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; const int flags = 0; id_size = 0; id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size); + id = id ? id : ""; settings_size = 0; settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size); + settings = settings ? settings : ""; size = id_size + 1 + settings_size + 1 + pkt->size; From patchwork Sun Jun 14 22:36: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: 20376 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 E15D344A534 for ; Mon, 15 Jun 2020 01:41:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB9AE68B700; Mon, 15 Jun 2020 01:41:51 +0300 (EEST) 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 9616768B6EA for ; Mon, 15 Jun 2020 01:41:50 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id x13so15179798wrv.4 for ; Sun, 14 Jun 2020 15:41: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=IAp9d7PALZ/LP65PUWQ/yluwkikWgTvREntj6PEroc4=; b=M9mBVL2CrBpnsYgS/Tfxz80/fJvCRfHwVNDlBY004XgbZ1e/sFYQ5MYbsi/Ca/yT+Z rFvPWUdoneY4QKw/amK28sIgTLkMmkFUbg21/V97H1rZGP0m5SQ9ncvSGWZf5N+SaYbh C+pAOgf9jGuJLnLfDq7ldSBaPNt9NbO4u1xrJx8Qlcu/fU+ypkipevIxYCX1FfngcHXZ RkKPaYc9YkvC2RQCm9Ho/h/FqfD8cEgY5NB3hYaekX6Y8ynyISFP0VF5PIt7HLFXEox0 6emQTkBMXSHJXev0GjqwhwKK3U58FKU1TGlY4ByEz5BbQQ1Qk5DrdXJ+2tSSqnkg/qZ4 JJBA== 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=IAp9d7PALZ/LP65PUWQ/yluwkikWgTvREntj6PEroc4=; b=Ej/EebasYK1xwRsvlrfYCZCQTAoiC0NwLhnYfCgcb4sKEC1YbHEGQNCvsqcp5UeuNF gicHFQ+dflWHOga3Z79COXnLAqUEjDbM0hcEEMWr0g4rlcp9KQc9ghPO22pWd08c9Lrm sjwpKZNJ8P0ycrLvBQC7EvVIr0OW7s+eAf4xTYU0KlfZKLUJfTb+//7W8qGzW24gj9pd dBSU6ytrod1hTr19cj3Rq0J7dTTYYhXzfyF+2Tlfh53q6ElP/Cx5EYGXXBbjSgdLPw1i KT6wkRSorpe+0JH4p9H19iKI5awDhRXmTp7WSrcNXPhOVk8XvWJegG+nefSehhscz8Op Lx4A== X-Gm-Message-State: AOAM530pcNGY2UZui5EquJ7sYM8luD8ep4X1p8w/X6luEtmTRL39pP20 5LtqjnrFv+jQ0DVPMwhLjF/hi8mr X-Google-Smtp-Source: ABdhPJw7S0/bLJeg/fvBk6i7k94MPXPx5oK1EKIltoqhyECLsUexYth9mfLbFREi8XzFkM/bnU4CIA== X-Received: by 2002:adf:ff8a:: with SMTP id j10mr25408208wrr.405.1592174509844; Sun, 14 Jun 2020 15:41:49 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:41:49 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:55 +0200 Message-Id: <20200614223656.21338-25-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/26] avformat/mov: Fix memleak upon encountering repeating tags 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" mov_read_custom tries to read three strings belonging to three different tags. When an already encountered tag is encountered again, a new buffer for the string to be read is allocated and stored in the pointer destined for this particular tag. But in this scenario, said pointer already holds the address of the string read earlier, leading to a leak. This commit aborts therefore aborts the reading process upon encountering an already encountered tag. Signed-off-by: Andreas Rheinhardt --- I don't know if one should error out in this scenario or not; or one could continue (i.e. use the already existing tag) or free the old one and use the new one. But this loop is only executed three times and all three tags need to be present for them to be of any use, so simply using continue in the scenario here would not be useful. libavformat/mov.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 47bbb3697d..a59c804d16 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4434,6 +4434,9 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom) } else break; + if (*p) + break; + *p = av_malloc(len + 1); if (!*p) { ret = AVERROR(ENOMEM); From patchwork Sun Jun 14 22:36: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: 20377 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 AAD8144A534 for ; Mon, 15 Jun 2020 01:41:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F34B68B71F; Mon, 15 Jun 2020 01:41:55 +0300 (EEST) 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 4EA0668B70F for ; Mon, 15 Jun 2020 01:41:54 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id q11so15191869wrp.3 for ; Sun, 14 Jun 2020 15:41:54 -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=R5+aGeixaz4KSpfS4tq5xZ4j+ZDT3yPI9gJsZSvq0no=; b=SqeJ/RuUCtT0kz6QmwP/e5+8AA/tZmDcrn2NMDvc7tBLEhubNdnoSjs1/e6fUvYybG +q7QeCOxBJZ4k3bNooo/NMY1jIf3QD9BqDMA+LDlwv6vAVereg6zVUev+xAfP/m4FGPe MG+Zo4OQY7CwDq3Y84HHJhTnyF/qNoJEet0PK2r3u9UAZu2wDQZ/+HqWtm/gEGlPSbre Hz7AvrI92RsPWI35u69er+H/Kbej0g7gIsYylRZB7RBZ3zXp0PPCHgJy1bYQaxJtz3tj YFO1y1U+NmyaA4OR9s3XI5SBTDu0lQQEr/SxNYhcZontg3hTDP2b8OwyOwqupqhjS5El jN5g== 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=R5+aGeixaz4KSpfS4tq5xZ4j+ZDT3yPI9gJsZSvq0no=; b=LgMOSTZ7SDqy+FSOgETmWZWgnPz3GWijguVOJFnh49taiSsadXA86z+eo6UFDGlb9X cJRvpYMwRUMetsYmaj63eZwT444nR97wjPDFdydOA4pYqPN0g6r/Q2ka9ZqviriUPm4B /lAGvUpAPFhs0LzgMLcEnLs0pOf1cTrTgosiwLZ2K+kqauvquRxbgouAihInAdf+UOy7 Tba2Rl9rADc9rnI6h0WQQbfhTrBiAZ5WzZuiRoN2YwG4gGwM1hnhwkExNYIKc1Ci//uT LPWWxOCUq4ncU2SbqOx4fy/V6N98ZbVkmyJxjynjs6i4mI7Q1J4oJydWkrfuIEPydtH+ wuGg== X-Gm-Message-State: AOAM533Kip8xDfurXVbD2b3GFyZQco//EwqxJLfeSXmKVuRJS004TlfF A7P85XTXJysTnxxd2F3BCCgJFlV7 X-Google-Smtp-Source: ABdhPJxwftNOaNdffmbrV/T8+j/UpwKrR2r1hLCmuDulIidbWt7714ZSfVKMozpqSS5mtnVCeZPtPQ== X-Received: by 2002:adf:f245:: with SMTP id b5mr25112542wrp.303.1592174513583; Sun, 14 Jun 2020 15:41:53 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:41:53 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:56 +0200 Message-Id: <20200614223656.21338-26-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/26] avformat/mov: Fix reel_name size check 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" Only read str_size bytes from offset 30 of extradata if the extradata is indeed at least 30 + str_size bytes long. Signed-off-by: Andreas Rheinhardt --- Honestly I don't know the spec describing the actual layout of the reel_name tag, but looking at this code as well as the one in movenc makes it clear that the check is wrong. libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index a59c804d16..4e68532b69 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2342,7 +2342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS uint32_t format = AV_RB32(st->codecpar->extradata + 22); if (format == AV_RB32("name") && (int64_t)size >= (int64_t)len + 18) { uint16_t str_size = AV_RB16(st->codecpar->extradata + 26); /* string length */ - if (str_size > 0 && size >= (int)str_size + 26) { + if (str_size > 0 && size >= (int)str_size + 30) { char *reel_name = av_malloc(str_size + 1); if (!reel_name) return AVERROR(ENOMEM); From patchwork Mon Jun 15 00:01: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: 20378 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 827A3448DD8 for ; Mon, 15 Jun 2020 03:02:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D90168B66F; Mon, 15 Jun 2020 03:02:28 +0300 (EEST) 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 3B3DA68B436 for ; Mon, 15 Jun 2020 03:02:22 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id c71so12876618wmd.5 for ; Sun, 14 Jun 2020 17:02:22 -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=ykd9nFw5RUaClGqbTg2Pgw1xw4q8oDvkbF0piTokE+E=; b=mSz06sVWDiR7uG3d5VL4k45Pvt2X4iQwApda1LDyJG8BrIrkOyUcZTsHb6atV217qR OfV6aUsycRdKFbLeuqp+ZJqVpsazEx0N7St1gJHiwU+a+9HCBiGPAybSvr6dHTk7MmU2 lIaB/ta7NwmE4GeeryXltuGh64+DEBcjsUsnbx8F0MbiB33pH6qTGABzqYGUmipq3pp4 aiyqntrE8e+yxo58y/Xy3fEmOOFKY5IbG91yFCXOSeRdXWZ997fs5m7F2Dkkc+Pak5JD C0mZY82H0Pplq7PCwrnrcce1FPlLV3fsPyzaV+AhcxL1OdAAkNFKNNgyX85pU8eduXwj i/OQ== 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=ykd9nFw5RUaClGqbTg2Pgw1xw4q8oDvkbF0piTokE+E=; b=c5WSdWv/lGBH5Emp6P2+4HxjSu/RoYwYFLzPk/Ltx5bBDW0Pf8ydLUlR2Y+POvYcko QNJ4iuRMUiSSwD+3FYsnK4Y0b8hcozKOIPv/vVBpy4ixq5huzVl8/u3o3t8d62TVTKXd Q1onqLi0wAnl4GIP5+MrY9fjhJGhv1t3cgQ+8J28E3UmqQTcBeYHc67RMs1gHCNlNvT3 y/Tl9S4bF3bVGnqLPY9Edut0XSDRBuZJu2OGdh+e8ZEDfzArTdnqGzzyr2QLDuHv6veH lyFyYRcOO1ICCyM/uh5zJ438FE51+gpVvp5QNlLF8QqBjl0kVS9JaB5JecqdfzwlVP1Z r1Ow== X-Gm-Message-State: AOAM531fhUwj0X0vjh84eE0HVrtKBJcucyUNIMVdmhyKth96JBRJK93P NKv47raxR/EYjKfGjGeqNwZH5Z89 X-Google-Smtp-Source: ABdhPJyuHi72xEX+vHT2mPSQ7Z6hZ4OQOuV0p3MvqomsB9DZktVS+UdEW2+x3sqAK123G4F5zPauYg== X-Received: by 2002:a05:600c:2110:: with SMTP id u16mr10042002wml.26.1592179341355; Sun, 14 Jun 2020 17:02:21 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:01:56 +0200 Message-Id: <20200615000204.10568-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/35] avformat/mov: Check earlier whether reel_name string is empty X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- This patch and all the following patches are not intended to be backported to 4.3. libavformat/mov.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4e68532b69..b2f2f8a3dd 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2342,18 +2342,15 @@ FF_ENABLE_DEPRECATION_WARNINGS uint32_t format = AV_RB32(st->codecpar->extradata + 22); if (format == AV_RB32("name") && (int64_t)size >= (int64_t)len + 18) { uint16_t str_size = AV_RB16(st->codecpar->extradata + 26); /* string length */ - if (str_size > 0 && size >= (int)str_size + 30) { + if (str_size > 0 && size >= (int)str_size + 30 && + st->codecpar->extradata[30] /* Don't add empty string */) { char *reel_name = av_malloc(str_size + 1); if (!reel_name) return AVERROR(ENOMEM); memcpy(reel_name, st->codecpar->extradata + 30, str_size); reel_name[str_size] = 0; /* Add null terminator */ - /* don't add reel_name if emtpy string */ - if (*reel_name == 0) { - av_free(reel_name); - } else { - av_dict_set(&st->metadata, "reel_name", reel_name, AV_DICT_DONT_STRDUP_VAL); - } + av_dict_set(&st->metadata, "reel_name", reel_name, + AV_DICT_DONT_STRDUP_VAL); } } } From patchwork Mon Jun 15 00:01:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20379 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 AA1A2448DD8 for ; Mon, 15 Jun 2020 03:02:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91A9E68B684; Mon, 15 Jun 2020 03:02:44 +0300 (EEST) 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 BE3E168B671 for ; Mon, 15 Jun 2020 03:02:38 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id x13so15262963wrv.4 for ; Sun, 14 Jun 2020 17:02: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=GEQSkh4Wi1MwULBKXH6ueW6FUlCakGkpDkA9EHVlBvw=; b=tCGio3CaveqiWskRBSWQD5419vlb+Afm4MgSs2Il5eAVu6tGooWDSEpift+VMUdolC lUMHw5RaDQ0waOH4wDpMndVSUZAPQ0Tw5fQTMUYmTDlKfgkgVOgDfNuuvqaH+keqeMsC LhnQoa6xqE3ceGpT4FZaQyoXnzw4dp5Jo3emjM9guPW1fQvsHQZBi7sp3jqEMpQlEXnn useTfJLd9ib05O3S4WdllNuS9yLPIuGonc9COcYHqjk7VhVCb2ayOvGk8bhlUPsOvxg2 cned3F0zSwCybft+qHa23V6RNuKusxO1WQSauoG8c+shm1POd6CFOoJmREoYpB5LxejB 32Kg== 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=GEQSkh4Wi1MwULBKXH6ueW6FUlCakGkpDkA9EHVlBvw=; b=leNU03l3MzJhx3kv/VXUniwQmUU1V8t1NtZVwfSDCkKz92cG0L2kdfse6+3aQ3N3kA JHwtZmVoSK5Fu7EYyQJzbM838vRNXeECj8yO+bPHyjkpQrrcXC8B9BM1GVZga+8NG3N/ a/MklMBqF7ASkbnOjh0ZlkA3WrzmvTjmXXFSwhekqSODTFsfCcu68mE1ABWZZ2Y3/CSQ /TG3x3DJIVFGovvFMM6KOZF6txAinKSbe6Qtrh67EMJ7kIwZKZmcCskApzHY4cEpaJ/u kGWKVMvfkqRZGkPXXZmUIJW4B6kVu4C24CTCDAMYcG+JaKadLKD6UiZSY1Ib56kSbEHv fmNQ== X-Gm-Message-State: AOAM532nI2BzTn8SG+23KGHj59DZnIFb6v5Md1r+OXdL5etdS6ReEWo7 1h4XlHC9YxLa5uIc+5LMtcgm0XHp X-Google-Smtp-Source: ABdhPJzSxRtOa98FKmEhPTEt92aFMjrqktjuT2tXpHAcm0/S3lf3k0aWlUt2/APU/v+1eS+wwDxddg== X-Received: by 2002:a5d:5092:: with SMTP id a18mr25841858wrt.42.1592179357878; Sun, 14 Jun 2020 17:02:37 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:37 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:01:57 +0200 Message-Id: <20200615000204.10568-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/35] avformat/mov: Read attached pics directly into st->attached_pic 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" Given that av_get_packet returns a blank packet on error, the only difference to the current approach (that uses intermediate AVPackets on the stack) is that st->attached_pic will be properly initialized on error (i.e. the timestamps are AV_NOPTS_VALUE) whereas right now st->attached_pic is only zeroed. Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index b2f2f8a3dd..72e868527a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -181,7 +181,6 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) { - AVPacket pkt; AVStream *st; MOVStreamContext *sc; enum AVCodecID id; @@ -205,12 +204,12 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) return AVERROR(ENOMEM); st->priv_data = sc; - ret = av_get_packet(pb, &pkt, len); + ret = av_get_packet(pb, &st->attached_pic, len); if (ret < 0) return ret; - if (pkt.size >= 8 && id != AV_CODEC_ID_BMP) { - if (AV_RB64(pkt.data) == 0x89504e470d0a1a0a) { + if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { + if (AV_RB64(st->attached_pic.data) == 0x89504e470d0a1a0a) { id = AV_CODEC_ID_PNG; } else { id = AV_CODEC_ID_MJPEG; @@ -219,7 +218,6 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) st->disposition |= AV_DISPOSITION_ATTACHED_PIC; - st->attached_pic = pkt; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; @@ -7184,17 +7182,15 @@ static void mov_read_chapters(AVFormatContext *s) st->disposition |= AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS; if (st->nb_index_entries) { // Retrieve the first frame, if possible - AVPacket pkt; AVIndexEntry *sample = &st->index_entries[0]; if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n"); goto finish; } - if (av_get_packet(sc->pb, &pkt, sample->size) < 0) + if (av_get_packet(sc->pb, &st->attached_pic, sample->size) < 0) goto finish; - st->attached_pic = pkt; st->attached_pic.stream_index = st->index; st->attached_pic.flags |= AV_PKT_FLAG_KEY; } From patchwork Mon Jun 15 00:01:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20380 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 BCA1E448DD8 for ; Mon, 15 Jun 2020 03:02:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A629168B6B1; Mon, 15 Jun 2020 03:02:46 +0300 (EEST) 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 A100168B694 for ; Mon, 15 Jun 2020 03:02:39 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id x13so15262985wrv.4 for ; Sun, 14 Jun 2020 17:02: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=QBfQh0OYynOo8sCizrwMqst8fh2pLT1lFaH0K5X43Rg=; b=JDP8LBMlh9AyIfwhLe1Qf0hunOmOniymGYwfgeqoy32bbJyE0/3wPhJLBFK3lhA5X1 mpdvqzI2QKWPjX5g+L1gnjxtbcrjrFtE+gQoMijPBvS7zIJEv1Cg0BgoLivylbMDGv6P 2/PWIyaflkcGpUj2DFwSuOHcGWT50FxR8PKJKjScW0DnWN2vmXM7twhLYWEEJB04y9SI /sgheWQter0DFH78MHaGC1oVTyf+EfHeV3VorCOg6+GEm702rQbH5sSiwrFppDV6h7sp Bh+7bZx1FMXKH29hRQjHrPAoCfM6AqB8faDztJM4BXA+/J1E1rx2Dhrej/tEqmNUeIJW l4jQ== 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=QBfQh0OYynOo8sCizrwMqst8fh2pLT1lFaH0K5X43Rg=; b=eXTLRHtbh7gjZAqqRAE089VciANa/JsEY4WrkdQTPSufapzpQvfcjFthsLpLnYhSqS 5Cg17caauo4kpVVCOpVOGoEdMYipZrouuu+3B9Qt2QPFVR++CjIy++llSyL/7+MQdG9A efC3N7jrTTnMtRx7WyEVhF8KVnj3p3JVTZ67Jt1exiBKZ7+Rte2kd1m5J5yydgY33C+X b5Akt8lyxpEo1PIwhnc0jTqD1EeeujzOaw4lcfFTSmKgbfLYQLJEDr+Zs+7f3IyboP3w ZcPtqrD26FyuLPdi93T/imyFWt2oNh2t1KdorrCU/GeQGASG8zWChAZL/ppm34WJic96 zjag== X-Gm-Message-State: AOAM53312X2tvSpflDIQbeTfhQeJagDlc/vrv8bkm466JRUNkfRV2BN4 mjuEx+0B1lplHJLvUPm46nONI9Xz X-Google-Smtp-Source: ABdhPJwVvlCBEYkLklK6HyGN50trylOANkvNhP1D6iVe6YvpbwqCjEq/LnYLAmV3jAN3Hglw0AssHg== X-Received: by 2002:a5d:4e03:: with SMTP id p3mr26523385wrt.350.1592179358904; Sun, 14 Jun 2020 17:02:38 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:38 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:01:58 +0200 Message-Id: <20200615000204.10568-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 29/35] avformat/mov: Avoid allocation+copy when moving extradata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 72e868527a..7c8c9bcb51 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2545,11 +2545,8 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) /* Move the current stream extradata to the stream context one. */ sc->extradata_size[pseudo_stream_id] = extra_size; - sc->extradata[pseudo_stream_id] = av_malloc(extra_size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!sc->extradata[pseudo_stream_id]) - return AVERROR(ENOMEM); - memcpy(sc->extradata[pseudo_stream_id], st->codecpar->extradata, extra_size); - av_freep(&st->codecpar->extradata); + sc->extradata[pseudo_stream_id] = st->codecpar->extradata; + st->codecpar->extradata = NULL; st->codecpar->extradata_size = 0; } sc->stsd_count++; From patchwork Mon Jun 15 00:01:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20381 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 BA3E6448DD8 for ; Mon, 15 Jun 2020 03:02:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A5D0468B6E3; Mon, 15 Jun 2020 03:02:49 +0300 (EEST) 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 0637D68B671 for ; Mon, 15 Jun 2020 03:02:41 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id l10so15236570wrr.10 for ; Sun, 14 Jun 2020 17:02: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=peZmbTRNdq+NgStaPPwo29i1sMQkP7lEF38rnFCOK+M=; b=l5hpilasUzVkapyOyJpL6HLUq5a7wooKHZIKJ3H2Mpl9meYLEScjUpeL1pIgweeEdk +/YxTls1Od60iOW4PQgqiDJ6wq6YZtYVCp0FRZJ7fGnsM53qNccKF0RTzUxGl8AN0MDa GqQn1fFd4HNvH5BOO4VMkmbLyzgFmnpmkW3eM4OweDiBbJY+eLmTJeh8LUJi8NDORhbB 4LVlU4lXnxcP6EizsIVjgD/rpg9ayDCBJ+hoNE+EEoxiEkMqZwBLx7VRPOBTMZtgqXj3 hFzW4ONWtxip6FxGElT2j3tiPjTU9N0lv6vfPX0lQQnuvATtrlfNEZpm3pNnXfrQgLCz XPkQ== 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=peZmbTRNdq+NgStaPPwo29i1sMQkP7lEF38rnFCOK+M=; b=TgDys7Oe6mUG3kRILZW3RP8g2SxEIh4Yym3NLOe/f/R3+mTdhvsDjPRaiUzwCqd/lD Za058Jh9DlLIuN0UtVHc3oFBvhhC0piG7tPm0HLjaLjTlh+IqjcXgwrlnBYA10Kn4ipw 60EAwVv20ATrP/J1UxGkxfKJHtD5yv8UCWfCh+sf6ymr5v4zvoNDx/MQ8BaJh6UDODLl m/XMbb+h++zpOIbzvnZ5zbXFJIWayRLlwvl2gdcSo4/qis0Xm77T9a3U5a28AD5D0a7A FtZQjruQ5u7uFOLJPeU8VraN+eexJmrXwzefPgXdaA+gXJvLqragzx8uiihufNG6IU82 aMGw== X-Gm-Message-State: AOAM532+qoV5EJeBk7DEgaTSAB+ZcQb9wrZdGdhibxqc1nWTNtgdWoWN XSWScDHEEA8+nua8Hx4kZGobqMR8 X-Google-Smtp-Source: ABdhPJx+kGQW2qEH2kJ/O2+Do1KV1YoUj4xSkXUWUe2YYA2aAArcmdklXmwaUcb1e7DvGje88JB6Qg== X-Received: by 2002:adf:fc81:: with SMTP id g1mr26792817wrr.156.1592179360155; Sun, 14 Jun 2020 17:02:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:01:59 +0200 Message-Id: <20200615000204.10568-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 30/35] avformat/mov: Use ffio_read_size where appropriate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 7c8c9bcb51..683ad49e7a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -863,14 +863,15 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) uint32_t frame_duration_code = 0; uint32_t channel_layout_code = 0; GetBitContext gb; + int ret; buf = av_malloc(ddts_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf) { return AVERROR(ENOMEM); } - if (avio_read(pb, buf, ddts_size) < ddts_size) { + if ((ret = ffio_read_size(pb, buf, ddts_size)) < 0) { av_free(buf); - return AVERROR_INVALIDDATA; + return ret; } init_get_bits(&gb, buf, 8*ddts_size); @@ -5765,12 +5766,9 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) st = c->fc->streams[c->fc->nb_streams - 1]; sc = st->priv_data; - ret = avio_read(pb, uuid, sizeof(uuid)); - if (ret < 0) { + ret = ffio_read_size(pb, uuid, sizeof(uuid)); + if (ret < 0) return ret; - } else if (ret != sizeof(uuid)) { - return AVERROR_INVALIDDATA; - } if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) { uint8_t *buffer, *ptr; char *endptr; @@ -5786,13 +5784,10 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!buffer) { return AVERROR(ENOMEM); } - ret = avio_read(pb, buffer, len); + ret = ffio_read_size(pb, buffer, len); if (ret < 0) { av_free(buffer); return ret; - } else if (ret != len) { - av_free(buffer); - return AVERROR_INVALIDDATA; } ptr = buffer; @@ -5823,13 +5818,10 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!buffer) { return AVERROR(ENOMEM); } - ret = avio_read(pb, buffer, len); + ret = ffio_read_size(pb, buffer, len); if (ret < 0) { av_free(buffer); return ret; - } else if (ret != len) { - av_free(buffer); - return AVERROR_INVALIDDATA; } buffer[len] = '\0'; av_dict_set(&c->fc->metadata, "xmp", @@ -5973,7 +5965,7 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AVEncryptionInfo **sample, int use_subsamples) { - int i; + int i, ret; unsigned int subsample_count; AVSubsampleEncryptionInfo *subsamples; @@ -5987,11 +5979,11 @@ static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVSt return AVERROR(ENOMEM); if (sc->cenc.per_sample_iv_size != 0) { - if (avio_read(pb, (*sample)->iv, sc->cenc.per_sample_iv_size) != sc->cenc.per_sample_iv_size) { + if ((ret = ffio_read_size(pb, (*sample)->iv, sc->cenc.per_sample_iv_size)) < 0) { av_log(c->fc, AV_LOG_ERROR, "failed to read the initialization vector\n"); av_encryption_info_free(*sample); *sample = NULL; - return AVERROR_INVALIDDATA; + return ret; } } @@ -6359,9 +6351,8 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!info) return AVERROR(ENOMEM); - if (avio_read(pb, info->system_id, 16) != 16) { + if ((ret = ffio_read_size(pb, info->system_id, 16)) < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to read the system id\n"); - ret = AVERROR_INVALIDDATA; goto finish; } @@ -6389,9 +6380,8 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) } info->num_key_ids = i + 1; - if (avio_read(pb, info->key_ids[i], 16) != 16) { + if ((ret = ffio_read_size(pb, info->key_ids[i], 16)) < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to read the key id\n"); - ret = AVERROR_INVALIDDATA; goto finish; } } From patchwork Mon Jun 15 00:02:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20383 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 566E0448DD8 for ; Mon, 15 Jun 2020 03:02:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4281F68B6F9; Mon, 15 Jun 2020 03:02:51 +0300 (EEST) 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 DE00368B6C3 for ; Mon, 15 Jun 2020 03:02:41 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id h5so15284085wrc.7 for ; Sun, 14 Jun 2020 17:02: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=i08n7GSVWvpSGWL4xs83LVtQwIn+JdaEdIgvLndarxc=; b=d2bXE6chbZ7RMIBIujRvL2mHFn/u+gFU5uwkVgSv+7Sh+JzTO5zRMYY+/C55wuIg01 OsZSSFZvdJkym1jH0Qgn4vkIkwpjumVtOwDfO1hJNAo/IBK/1OeIkkOmwSMZH5fxmYuu bLdixQ0uWTS2kY2RlZR7JlApXrBypTc6iOuLdEHk8Q6RpamK0ZLJ9mMvhS1weTd4Vvp3 uqpn6xZXZM1TZ/ot/yFGlOOJp2oDcZNpfPxwbY5WuHRUC++sot1l2O4EWtqGxM1H1a30 6OO5QB7ZHnDn9Bw3JsFZHTxKPEcrUN5z6c7C/GiTDhxZ2aZbQuVbkRYDxah1Lpxv5x/9 mk3A== 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=i08n7GSVWvpSGWL4xs83LVtQwIn+JdaEdIgvLndarxc=; b=sYSn4aaBYK8q6w6srin4wnKdF3e8rROgnd/ORTMmacNjJ5sXNyPD/luFqHVAgfUICu UNVb6zlQLUEKb4K5rtDgSFsJ4dJNHM7jV5jNZAs84pimSUz0WXISQ0VyZQ42kvcW0Vfw xBTAauS1cdCJ5u/mGDtOmTyG8iQg5W7MzUavfrKglJ/42TWKjybj3/bOEDWv30MukfKD 75aoRw75IBCwtWz5X9s+TElpVQHOn2jyRuWiQJ79awtzVurPHhOJhQ+LquIUUs10nNEp d6W5OtIfHR2ln3xAc+oZGdqQhPgfOMYdbZpMpoXeJEm7eZC8q38VMMqLhuuMHH3/AVQt TK/w== X-Gm-Message-State: AOAM532mycKhjPp470LcDtbmzcF0xSQ777CYm7y67SMyZYJk+ytIStGB Ph91j+VhNqxIkANDovYF5hJoVKfO X-Google-Smtp-Source: ABdhPJxD78psfOKrYk+Dqo2Dv6dH0xHWrSkLuKQkXsn4rKAwgCEAdmsBMhvTLIDanmdJlsT7nbLwfw== X-Received: by 2002:a5d:69cb:: with SMTP id s11mr26070597wrw.91.1592179361069; Sun, 14 Jun 2020 17:02:41 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:02:00 +0200 Message-Id: <20200615000204.10568-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 31/35] avformat/mov: Avoid allocation when reading ddts atom X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 683ad49e7a..8bc220408c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -857,27 +857,20 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) { - const uint32_t ddts_size = 20; +#define DDTS_SIZE 20 + uint8_t buf[DDTS_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVStream *st = NULL; - uint8_t *buf = NULL; uint32_t frame_duration_code = 0; uint32_t channel_layout_code = 0; GetBitContext gb; int ret; - buf = av_malloc(ddts_size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!buf) { - return AVERROR(ENOMEM); - } - if ((ret = ffio_read_size(pb, buf, ddts_size)) < 0) { - av_free(buf); + if ((ret = ffio_read_size(pb, buf, DDTS_SIZE)) < 0) return ret; - } - init_get_bits(&gb, buf, 8*ddts_size); + init_get_bits(&gb, buf, 8 * DDTS_SIZE); if (c->fc->nb_streams < 1) { - av_free(buf); return 0; } st = c->fc->streams[c->fc->nb_streams-1]; @@ -885,7 +878,6 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->sample_rate = get_bits_long(&gb, 32); if (st->codecpar->sample_rate <= 0) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate); - av_free(buf); return AVERROR_INVALIDDATA; } skip_bits_long(&gb, 32); /* max bitrate */ @@ -913,7 +905,6 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) ((channel_layout_code & 0x8) ? AV_CH_LOW_FREQUENCY : 0); st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout); - av_free(buf); return 0; } From patchwork Mon Jun 15 00:02:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20384 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 799D4448DD8 for ; Mon, 15 Jun 2020 03:02:52 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 69CFA68B6F6; Mon, 15 Jun 2020 03:02:52 +0300 (EEST) 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 145A668B671 for ; Mon, 15 Jun 2020 03:02:43 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id l11so15269983wru.0 for ; Sun, 14 Jun 2020 17:02: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=VTA6Ke77F+59JDTGd/ZkORCtRnyC4sb7Yk19HirgA1Y=; b=ed7R4AsrxQjvd6r+8P2vQgzUnRYfJmksJkZ6YTnOHbEn7PWiDQ9bdJ+/gyg6XsX1pp qQY9OLvmUk6Dj3ulzQlx4w0hC0smORpZiqquDFje1/sk/gnYiADA3qoeZ/pit+IoAPCU OD8e3j6AQL3O9w2R0PEcfylTAGv07iWimxRb88G5LDys8MTc2AXynm/JbgqKzmdVZnls pDXdDboLM9rO18I3If8q2DE4bFJZ2w0GYsgP2ISVjrUBkwLMn32/Sh6PQquN6GRz2Lv/ WxQJYTDmUEH1ByUyV3wtWKwoAONxFedKTe3ukB4Ugk/fIj97kapGLyP9UH+sdW2PTIIc vI4A== 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=VTA6Ke77F+59JDTGd/ZkORCtRnyC4sb7Yk19HirgA1Y=; b=o0ZPg5xCaFVQDZvxoIBlxubJKH6ZtWCw5SqEHfENuS67qP9FLai32AEbHM0guKecWL Lu8eOFmh+/qK+UPHaOJycOmlEwaCwHSQf4mQbHwQyF46kVbb/oaLKsfm8QMCrFdopBRG kkM4p919zQ1EDknhVPewXW6S9OJEHRqyyfBeIuBLWesAP5w9W2xhCRktNDcmpymR+MXK HEllmXimu2rnZ8tslha72eG1Phbn+FX7X60ZrKhaEbhAKg79G47MoLdPXFHoHf1eK5/E scNhILWtcYv2we50LOnVs58rWCc4st5c/w5WpybPjIlsG47JKRnEjByU3pxYIx7P1cgZ 2Oyw== X-Gm-Message-State: AOAM5329NmpdtH/QJm3vWDEGjPVWBF0fofkDlM5Fv4U1oyMXgPU5XZou 1hbLq+wuRcw6IoW2U5la0qs8+5rg X-Google-Smtp-Source: ABdhPJx/akXBDuvQW5V2C0Jx101iEPDy7pmJOQSn3gYGL6nBgvzJ5IAW9nCRyb7bXV2N+21+yi7ALg== X-Received: by 2002:a5d:4bc5:: with SMTP id l5mr26468407wrt.104.1592179362056; Sun, 14 Jun 2020 17:02:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:02:01 +0200 Message-Id: <20200615000204.10568-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 32/35] avformat/mov: Cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 112 ++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8bc220408c..e30cd1ef1a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -644,7 +644,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_skip(pb, 16); for (type = 0; type != -1 && avio_tell(pb) < next; ) { - if(avio_feof(pb)) + if (avio_feof(pb)) return AVERROR_EOF; type = avio_rb16(pb); len = avio_rb16(pb); @@ -1308,7 +1308,7 @@ static int update_frag_index(MOVContext *c, int64_t offset) &c->frag_index.allocated_size, (c->frag_index.nb_items + 1) * sizeof(*c->frag_index.item)); - if(!item) + if (!item) return -1; c->frag_index.item = item; @@ -1392,7 +1392,7 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx) { if (time) { - if(time >= 2082844800) + if (time >= 2082844800) time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ if ((int64_t)(time * 1000000ULL) / 1000000 != time) { @@ -1566,8 +1566,7 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom) ret = ffio_read_size(pb, icc_profile, atom.size - 4); if (ret < 0) return ret; - } - else { + } else { color_primaries = avio_rb16(pb); color_trc = avio_rb16(pb); color_matrix = avio_rb16(pb); @@ -1720,7 +1719,7 @@ static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom) { int ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_AVUI); - if(ret == 0) + if (!ret) ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_DNXHD); return ret; } @@ -2765,8 +2764,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_TRACE, "keyframe_count = %u\n", entries); - if (!entries) - { + if (!entries) { sc->keyframe_absent = 1; if (!st->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) st->need_parsing = AVSTREAM_PARSE_HEADERS; @@ -2894,8 +2892,8 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) AVStream *st; MOVStreamContext *sc; unsigned int i, entries, alloc_size = 0; - int64_t duration=0; - int64_t total_sample_count=0; + int64_t duration = 0; + int64_t total_sample_count = 0; if (c->fc->nb_streams < 1) return 0; @@ -2930,7 +2928,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->stts_count = min_entries; sc->stts_data = stts_data; - sample_count=avio_rb32(pb); + sample_count = avio_rb32(pb); sample_duration = avio_rb32(pb); sc->stts_data[i].count= sample_count; @@ -2947,8 +2945,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (duration > 0 && duration <= INT64_MAX - sc->duration_for_fps && - total_sample_count <= INT_MAX - sc->nb_frames_for_fps - ) { + total_sample_count <= INT_MAX - sc->nb_frames_for_fps) { sc->duration_for_fps += duration; sc->nb_frames_for_fps += total_sample_count; } @@ -3037,8 +3034,8 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); for (i = 0; i < entries && !pb->eof_reached; i++) { - int count =avio_rb32(pb); - int duration =avio_rb32(pb); + int count = avio_rb32(pb); + int duration = avio_rb32(pb); if (count <= 0) { av_log(c->fc, AV_LOG_TRACE, @@ -3278,13 +3275,13 @@ static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, FFMAX(min_size_needed, 2 * st->index_entries_allocated_size) : min_size_needed; - if((unsigned)st->nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry)) + if (st->nb_index_entries + 1U >= UINT_MAX / sizeof(AVIndexEntry)) return -1; entries = av_fast_realloc(st->index_entries, &st->index_entries_allocated_size, requested_size); - if(!entries) + if (!entries) return -1; st->index_entries= entries; @@ -3329,12 +3326,12 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, uns FFMAX(min_size_needed, 2 * (*allocated_size)) : min_size_needed; - if((unsigned)(*ctts_count) >= UINT_MAX / sizeof(MOVStts) - 1) + if ((unsigned)(*ctts_count) >= UINT_MAX / sizeof(MOVStts) - 1) return -1; ctts_buf_new = av_fast_realloc(*ctts_data, allocated_size, requested_size); - if(!ctts_buf_new) + if (!ctts_buf_new) return -1; *ctts_data = ctts_buf_new; @@ -3347,7 +3344,8 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, uns } #define MAX_REORDER_DELAY 16 -static void mov_estimate_video_delay(MOVContext *c, AVStream* st) { +static void mov_estimate_video_delay(MOVContext *c, AVStream* st) +{ MOVStreamContext *msc = st->priv_data; int ind; int ctts_ind = 0; @@ -3362,7 +3360,7 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) { if (st->codecpar->video_delay <= 0 && msc->ctts_data && st->codecpar->codec_id == AV_CODEC_ID_H264) { st->codecpar->video_delay = 0; - for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) { + for (ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) { // Point j to the last elem of the buffer and insert the current pts there. j = buf_start; buf_start = (buf_start + 1); @@ -4160,10 +4158,10 @@ static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDr return AVERROR(ENOENT); } - if(strstr(ref->path + l + 1, "..") || - strstr(ref->path + l + 1, ":") || - (ref->nlvl_from > 1 && same_origin < 0) || - (filename[0] == '/' && src_path == src)) + if (strstr(ref->path + l + 1, "..") || + strstr(ref->path + l + 1, ":") || + (ref->nlvl_from > 1 && same_origin < 0) || + (filename[0] == '/' && src_path == src)) return AVERROR(ENOENT); } @@ -4797,8 +4795,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); frag_stream_info = get_current_frag_stream_info(&c->frag_index); - if (frag_stream_info) - { + if (frag_stream_info) { if (frag_stream_info->next_trun_dts != AV_NOPTS_VALUE) { dts = frag_stream_info->next_trun_dts - sc->time_offset; } else if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE && @@ -4847,7 +4844,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) new_entries = av_fast_realloc(st->index_entries, &st->index_entries_allocated_size, requested_size); - if(!new_entries) + if (!new_entries) return AVERROR(ENOMEM); st->index_entries= new_entries; @@ -6591,15 +6588,13 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s av_aes_ctr_set_full_iv(sc->cenc.aes_ctr, sample->iv); - if (!sample->subsample_count) - { + if (!sample->subsample_count) { /* decrypt the whole packet */ av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size); return 0; } - for (i = 0; i < sample->subsample_count; i++) - { + for (i = 0; i < sample->subsample_count; i++) { if (sample->subsamples[i].bytes_of_clear_data + sample->subsamples[i].bytes_of_protected_data > size) { av_log(c->fc, AV_LOG_ERROR, "subsample size exceeds the packet size left\n"); return AVERROR_INVALIDDATA; @@ -6962,10 +6957,9 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) } } if (atom.type != MKTAG('r','o','o','t') && - atom.type != MKTAG('m','o','o','v')) - { - if (a.type == MKTAG('t','r','a','k') || a.type == MKTAG('m','d','a','t')) - { + atom.type != MKTAG('m','o','o','v')) { + if (a.type == MKTAG('t','r','a','k') || + a.type == MKTAG('m','d','a','t')) { av_log(c->fc, AV_LOG_ERROR, "Broken file, trak/mdat not at top-level\n"); avio_skip(pb, -8); c->atom_depth --; @@ -7105,25 +7099,26 @@ static int mov_probe(const AVProbeData *p) offset = FFMAX(4, AV_RB32(p->buf+offset)) + offset; } } - if(score > AVPROBE_SCORE_MAX - 50 && moov_offset != -1) { + if (score > AVPROBE_SCORE_MAX - 50 && moov_offset != -1) { /* moov atom in the header - we should make sure that this is not a * MOV-packed MPEG-PS */ offset = moov_offset; - while(offset < (p->buf_size - 16)){ /* Sufficient space */ + while (offset < (p->buf_size - 16)) { /* Sufficient space */ /* We found an actual hdlr atom */ - if(AV_RL32(p->buf + offset ) == MKTAG('h','d','l','r') && - AV_RL32(p->buf + offset + 8) == MKTAG('m','h','l','r') && - AV_RL32(p->buf + offset + 12) == MKTAG('M','P','E','G')){ + if (AV_RL32(p->buf + offset ) == MKTAG('h','d','l','r') && + AV_RL32(p->buf + offset + 8) == MKTAG('m','h','l','r') && + AV_RL32(p->buf + offset + 12) == MKTAG('M','P','E','G')) { av_log(NULL, AV_LOG_WARNING, "Found media data tag MPEG indicating this is a MOV-packed MPEG-PS.\n"); /* We found a media handler reference atom describing an * MPEG-PS-in-MOV, return a * low score to force expanding the probe window until * mpegps_probe finds what it needs */ return 5; - }else + } else { /* Keep looking */ - offset+=2; + offset += 2; + } } } @@ -7600,7 +7595,8 @@ static int mov_read_header(AVFormatContext *s) AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; fix_timescale(mov, sc); - if(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AAC) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + st->codecpar->codec_id == AV_CODEC_ID_AAC) { st->skip_samples = sc->start_pad; } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0) @@ -7618,8 +7614,7 @@ static int mov_read_header(AVFormatContext *s) } if (mov->handbrake_version && mov->handbrake_version <= 1000000*0 + 1000*10 + 2 && // 0.10.2 - st->codecpar->codec_id == AV_CODEC_ID_MP3 - ) { + st->codecpar->codec_id == AV_CODEC_ID_MP3) { av_log(s, AV_LOG_VERBOSE, "Forcing full parsing for mp3 stream\n"); st->need_parsing = AVSTREAM_PARSE_FULL; } @@ -7673,9 +7668,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) { + if (err < 0) goto fail; - } break; case AVMEDIA_TYPE_VIDEO: if (sc->display_matrix) { @@ -7868,7 +7862,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_INVALIDDATA; } - if( st->discard == AVDISCARD_NONKEY && 0==(sample->flags & AVINDEX_KEYFRAME) ) { + if (st->discard == AVDISCARD_NONKEY && !(sample->flags & AVINDEX_KEYFRAME)) { av_log(mov->fc, AV_LOG_DEBUG, "Nonkey frame from stream %d discarded due to AVDISCARD_NONKEY\n", sc->ffindex); goto retry; } @@ -8026,17 +8020,17 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, /* adjust stsd index */ if (sc->chunk_count) { - time_sample = 0; - for (i = 0; i < sc->stsc_count; i++) { - int64_t next = time_sample + mov_get_stsc_samples(sc, i); - if (next > sc->current_sample) { - sc->stsc_index = i; - sc->stsc_sample = sc->current_sample - time_sample; - break; + time_sample = 0; + for (i = 0; i < sc->stsc_count; i++) { + int64_t next = time_sample + mov_get_stsc_samples(sc, i); + if (next > sc->current_sample) { + sc->stsc_index = i; + sc->stsc_sample = sc->current_sample - time_sample; + break; + } + av_assert0(next == (int)next); + time_sample = next; } - av_assert0(next == (int)next); - time_sample = next; - } } return sample; From patchwork Mon Jun 15 00:02:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20385 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 7CA22448DD8 for ; Mon, 15 Jun 2020 03:02:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65F2E68B711; Mon, 15 Jun 2020 03:02:53 +0300 (EEST) 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 1D7C468B68D for ; Mon, 15 Jun 2020 03:02:44 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id t18so15266104wru.6 for ; Sun, 14 Jun 2020 17:02: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=XECO06i/Py/ocxy9O/LII+cgrSSfR6vc80so/7TuZlo=; b=NJicPN2UuxDO5nxqFGvewc708cXOfY+uW73hhNZIW4JnDdU4/fdRA5NIkyh8S+rIUl UFdvabngupxWm28TTLtOEM41+NJCYrXLoyJqSy8l8Fhb4j47ZYgl2pS2EnW7VeYri2GQ ClqKnQJrowFMGo/cgGoV6UGVninwZUoyaNRPpjfi2AIDHYjoBSNSG6eMSex9eNFUN7K+ LXZKEIBR8fJ8IvPmpJxT8a7M5PihizfGEMQrkQroXBXz/hfbRaKe36CBYkQxMt/NZEv0 daCJ7M32IEKA1rlgFGJ+YVOAck68sDsD+5fq6+q6wVryzS5iaMljJuPEkExp5+RvP63C cYoA== 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=XECO06i/Py/ocxy9O/LII+cgrSSfR6vc80so/7TuZlo=; b=JWZo2coeYUilAuKkozYNwQNcUNlyH3xk0cvH872nUAR3yllp8N/gdZWL0UvMzj/cp/ mhZFDMn6lNirT5HqVVHQsR5wFBzYajHQk4WVbwXDtAELkbxxo+DP/INEmtDwDModzpT9 23U2q5umegw8QzWtIatRlJ9KeGS5eB8MFxLCHYgleWTdU50ffKUWT2dx4pPAlN5zPIIR EFMO7vnrB5pfE2hfHpqVE0dmOT+3b+Kbw68C899lTRYvAr5yMVLFwLSFcSij7i2PWtma 4r2oy/zchFf5N5JGEbv/WyMdFJG5ayuf/qcKS2vWQOXZ3UuOrgwhPjsWX7Wy9ssveJFX ltMA== X-Gm-Message-State: AOAM531b7jfZ3CIzYC5QGmjxlSo+LxO94TVIggfQQQmbvnCXmcNX3G8O zlHSBVSG5lbdCx2Fnb0NcqRsDwsO X-Google-Smtp-Source: ABdhPJwXSWIFFnyW3q071P9xcr/gWcAr+bo46+2LC2qVmpJRVjLRHDuaN4l5e7DopfKruFsrlX94JA== X-Received: by 2002:a5d:4484:: with SMTP id j4mr25433447wrq.325.1592179363183; Sun, 14 Jun 2020 17:02:43 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:42 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:02:02 +0200 Message-Id: <20200615000204.10568-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 33/35] avformat/mpl2dec: Avoid variable that is always zero X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mpl2dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c index bea258d9e9..38445c7aad 100644 --- a/libavformat/mpl2dec.c +++ b/libavformat/mpl2dec.c @@ -83,7 +83,6 @@ static int mpl2_read_header(AVFormatContext *s) { MPL2Context *mpl2 = s->priv_data; AVStream *st = avformat_new_stream(s, NULL); - int res = 0; if (!st) return AVERROR(ENOMEM); @@ -122,7 +121,7 @@ static int mpl2_read_header(AVFormatContext *s) } ff_subtitles_queue_finalize(s, &mpl2->q); - return res; + return 0; } static int mpl2_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Mon Jun 15 00:02:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20386 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 37A1D448DD8 for ; Mon, 15 Jun 2020 03:02:54 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 266EB68B71F; Mon, 15 Jun 2020 03:02:54 +0300 (EEST) 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 78F5E68B67E for ; Mon, 15 Jun 2020 03:02:45 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id p5so15237652wrw.9 for ; Sun, 14 Jun 2020 17:02: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=Lu8jIuOJFdcShMoXGXrksfcG+cLTqNlXi2c0awDjkN0=; b=huXRN4C8IEVIVyxhhPqThTTciLCHN4ReY+p9pV0y3w+ZZZA9Ep8k7v7nPYz0A5habJ L10X86vtLdt/DeeOcma1xFoE8HYVd3qScLX1ijZLjPQ6EfXetoLeYPHzFxAo9S4xs54b XvI52R/EhbTltOsB9uWBrRGafyeNn3NzL2G08wNV1tzFLhKWczhQMg7+cacgOzcjhpl5 aJdXitRuHmEuH9MA2hqzjpBEqOSrYEBdZcla7U/jt94MhJiPYk02TJBonvAiBwrb/frG lleHd24QsDM80lvPjK3zFr4OM+ah97QyaCeYSljHX8rbfwrfAEI11wyP1lRyZ7kHOIfS ph7g== 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=Lu8jIuOJFdcShMoXGXrksfcG+cLTqNlXi2c0awDjkN0=; b=sg+QlNwRfAcp76QoXsh3drIcSthf3AGamAepvPjebOphOrkpybt7ERzDTKPpzW2c4X vMJbjUkV2o75W4AE89o6DUwfVQFshzskTg3C79F3sJtysIqsvY4Q0d9osrWmW14iyKx2 JuFebSDp3iYxFOcAJzHfROj3Ual8trNaQ7B2H8IaKpruBmlgnES/OF2Ck9u7qUu8OvGu CYfIk6b8TLeK0Q9M7Mw+8IIr4ZFGavGjPsBQm6o/tCks9bs/BfK0M16scWqhBtWcZqZX Mts+fAVOFjc0ARAaVPhTTWoBh7kKzyb8Gw0SxKAODfCZ8TVHtS7bxvX74FFpcc8D3MX1 T6Lg== X-Gm-Message-State: AOAM531oS0nZA41AcxsIZFkc7CqOSzWBN2aXeAz+V+ND/GQVFVBV4dF1 +d4vlcfRMdeUKeGAXynt9LJpClBB X-Google-Smtp-Source: ABdhPJxdHrxwJ7sN5VTwHIjVHehRi7yXZZPYXXqCQMu/2SBU/ZQjLboqB25Ujk/abrW+Yot++4hsvg== X-Received: by 2002:adf:f003:: with SMTP id j3mr26206265wro.228.1592179364708; Sun, 14 Jun 2020 17:02:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:02:03 +0200 Message-Id: <20200615000204.10568-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 34/35] avformat/pjsdec: Avoid variable that is always zero X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/pjsdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c index e30c23d830..1f1d51c404 100644 --- a/libavformat/pjsdec.c +++ b/libavformat/pjsdec.c @@ -67,7 +67,6 @@ static int pjs_read_header(AVFormatContext *s) { PJSContext *pjs = s->priv_data; AVStream *st = avformat_new_stream(s, NULL); - int res = 0; if (!st) return AVERROR(ENOMEM); @@ -105,7 +104,7 @@ static int pjs_read_header(AVFormatContext *s) } ff_subtitles_queue_finalize(s, &pjs->q); - return res; + return 0; } static int pjs_read_packet(AVFormatContext *s, AVPacket *pkt) From patchwork Mon Jun 15 00:02:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20382 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 91912448DD8 for ; Mon, 15 Jun 2020 03:02:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8308A68B6F3; Mon, 15 Jun 2020 03:02:50 +0300 (EEST) 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 C275F68B6C2 for ; Mon, 15 Jun 2020 03:02:46 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id l10so15236675wrr.10 for ; Sun, 14 Jun 2020 17:02: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=VEpIC8dJ7xy5zia9YS3Dxx8MIzXozq/p37FeK1nNY8k=; b=HYkHxNJeX87Hi8WTMbfviKthoAIR2vYC0/bdD2RVyVks5O2m+qmgd/IzLDCoisHQDi J6U56sNDCr2E+xts+vfBj2ZAGIdb8tjEJi1qMD1k3o/20ATL0nQf0uf3BifI7/XMreic zefHflbuu53PYqGMp/uaUDQTLpEeUs/A81/SY+panhQdx0mYVOH0Xt72i8I9uhl50aFY zfONBSX6K8YtApShCFNYCGwTxcKeRLX6nIA2/mDDzes9/Pzjt4NmgRm7EDtAG0tV/pTB HhrKko4vf5cKwrCuRTOr9uPLfWXhsiDlGIqSqNptz9ZgusS9/6OGoF/OJMAnN0fCGkp0 HHqA== 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=VEpIC8dJ7xy5zia9YS3Dxx8MIzXozq/p37FeK1nNY8k=; b=bnKgU1zJwS2/I3J1vBE7s6U3G+rMrj1ue9GjN9w/YILx/n1uzj+N7bZV0ASwOoDRnb KDhch6RroZAqODUW1Zu/jzotNFFR+1luw7fDFmoC6HmP4NDKZvb524WytQiE6fr6u+fZ uVFDSqyxZiLpe4VRaaGCTPl8kvV331zngEDSkA0N0iZSU9/mcE+Lvj1rpj5oQNSvoAm5 eV5k6TRI4B2mNPRC9a8ldHsypfVqz8IV5rHuJ/Hf2pCJ4z9EG/rp7Dk55nqWpuscZ8aA Z3dxrI0lklmmNIZVxRbCuRixiumROWftt151PlPPECEiRqlwDNIdau3qsLCeXcqGqTav 0ZUQ== X-Gm-Message-State: AOAM5317VCH3EQfmg5pnidHHZGv0KNYIUBvYS5GcLkA1iUO3QpzcSOJX d1k+Cl29o97Nm3a/jhGZe+635xv1 X-Google-Smtp-Source: ABdhPJzkc7CMTHLNFHfyGzI912IQTIeR1KRVB53SeyfwJ5lcDKRVmLSD4miQJu/d8HZ/dGIcOyKZng== X-Received: by 2002:adf:de84:: with SMTP id w4mr26492324wrl.54.1592179365988; Sun, 14 Jun 2020 17:02:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:45 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:02:04 +0200 Message-Id: <20200615000204.10568-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 35/35] avformat/sccdec: Avoid variable that is always zero X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/sccdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c index 72f47f70de..c08c58ef97 100644 --- a/libavformat/sccdec.c +++ b/libavformat/sccdec.c @@ -66,7 +66,7 @@ static int scc_read_header(AVFormatContext *s) char line[4096], line2[4096]; int64_t current_pos, next_pos; int64_t ts_start, ts_end; - int count = 0, ret = 0; + int count = 0; ptrdiff_t len2, len; uint8_t out[4096]; FFTextReader tr; @@ -177,7 +177,7 @@ try_again: ff_subtitles_queue_finalize(s, &scc->q); - return ret; + return 0; fail: ff_subtitles_queue_clean(&scc->q); return AVERROR(ENOMEM);