From patchwork Fri Jun 21 13:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 13661 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 39FF84451F9 for ; Fri, 21 Jun 2019 16:42:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 120DE68A9D4; Fri, 21 Jun 2019 16:42:56 +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 7BEC268A96C for ; Fri, 21 Jun 2019 16:42:49 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id x17so6619864wrl.9 for ; Fri, 21 Jun 2019 06:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=BihG2ep1kwSP8n/7fHcabv078HMJbX+ZyyTK8lZ+980=; b=SeRKhdeCPXe8oq2Ir4aPA2uw12lmLKXCwwaSoyrRvnK47trxE+kKeW63kzIWYwKOoO vJPIrPC4Lf1e7cfW5W71XbmdUySKiVnWTUD2aRu566xlSP+IhUhdKkhmHCO6OS8R12wm wjExbCercnEYkhHfi6oBbgDET22x7hlT7oapa0xaJcQYl1YO02zzEGvuT22Vy9TMc4U7 cSg6Zvq7oygHKNkmxPjxNeItMlZar9sCG+4Ibg/RJ0ChZm51DUPn1tXGfkcCKNvjxY2n 5ORODfIbws7MZ540ljkpgLo3KHTnLFaWA46NGyawLY/viw4c8Ncy9Mb5akmzoQoVQSMc 0ctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=BihG2ep1kwSP8n/7fHcabv078HMJbX+ZyyTK8lZ+980=; b=D/RCf6qYMhBqnfU5SxP9FxEzbzM6aeblfCIyS8skwzXkS3ZpQ8coAC6f2rcQ6Ky4tF lryBYv1r8Pjgk4NYQxhPbcrJ7DDK0rOoPsGT0Vui7pu/0Meq6eQNyYCXPaesCxTPSdz8 INKQFdL+lK5fw41jiI+b5KogrTw64J/940ZWP5cWd5gjr6GZEZON+ytCPVj4jQxiORKv z/XFA01hVKKtePoNfHf+Lm8qJtGj0rd9ehh8EFPEdSLbMlRSBDZNBSoeUwpP25oPy47T Is0pw4xKVT3XrFt002B59qMbu2KPRJg/MnCPjCagAwv+Kxi4I/wDXiH3rhcGyvYDUfrZ mGsw== X-Gm-Message-State: APjAAAVTap6sfKPgfOsipqJAFSC4UjCSRYb6CyHgYsPjB7cVPYHpNpEX x8+szrxJmNVaaZaczUsRNuqA3Fz9 X-Google-Smtp-Source: APXvYqxEPnY3qSsa38TVm1rjpaz+suU1/6SRb1/T+hwG4C8hIeMUjecRK2E5VGcz73t1xESRFO1vdw== X-Received: by 2002:adf:cc92:: with SMTP id p18mr50613911wrj.260.1561124226322; Fri, 21 Jun 2019 06:37:06 -0700 (PDT) Received: from localhost.localdomain ([82.129.87.116]) by smtp.gmail.com with ESMTPSA id t12sm3467188wrw.53.2019.06.21.06.37.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 06:37:05 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Jun 2019 14:36:55 +0100 Message-Id: <20190621133656.21006-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] ffprobe: Fix memory leak 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This packet was not necessarily unreferenced. Signed-off-by: Derek Buitenhuis --- fftools/ffprobe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 3becb6330e..52f24e7dfd 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2351,6 +2351,7 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, int ret = 0, i = 0, frame_count = 0; int64_t start = -INT64_MAX, end = interval->end; int has_start = 0, has_end = interval->has_end && !interval->end_is_offset; + int needs_unref = 0; av_init_packet(&pkt); @@ -2410,9 +2411,12 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, } if (interval->end_is_offset && interval->duration_frames) { - if (frame_count >= interval->end) + if (frame_count >= interval->end) { + needs_unref = 1; break; + } } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) { + needs_unref = 1; break; } @@ -2429,6 +2433,10 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, } av_packet_unref(&pkt); } + + if (needs_unref) + av_packet_unref(&pkt); + av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0;