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)