From patchwork Wed Sep 11 12:36:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15019 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 BEE56448C8C for ; Wed, 11 Sep 2019 15:45:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A54D687F55; Wed, 11 Sep 2019 15:45:06 +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 B3AC2687F4A for ; Wed, 11 Sep 2019 15:44:59 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id t9so3374707wmi.5 for ; Wed, 11 Sep 2019 05:44:59 -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=pl0glDxNl4ONMGb8PbXee3mk6T452d/71D8HJQEbGOY=; b=KFMfy4XEOFBK2t5mcmNeqwetwLEkX6GGW3N81ygUjh/8WWysMddD1vcpng8lcmeIsI BJKbju7jJp3u8qqCHfCsSZ2SIpjTh9a4O+Ff3SEWyiua8yuan8bm2EWTPioGy0Y8g9yN bFrVqfL+KSrQadn9urdoR+qWW26n6lyJgdnqHnNqzisJc/VlJdXlAUzXsasCLzJlQNdC R+mQUUQAgLzA+OGoTe4efVm/G+Hcq8+4sDlRwJxj8DpQWlJaReaJjOZsnjpjGVbcfpZL aHp0retj/hGU2z4rNiaqHmoL5XnO+trjRz4U7CwllDX9PDh4liH5xRql6LD2nGslmua2 Fo1g== 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=pl0glDxNl4ONMGb8PbXee3mk6T452d/71D8HJQEbGOY=; b=a++a6xC9LRz1Pyh9t0h0lu/q+CLGWe9kZX1gPHs2acXywfaftesgkbqWpA07bcz9iv ZDEqWvT2jP9KX9wTVMChH5K7/P3xK1mHY+HZgKSFU145e+rB5HrYkkZTDv0EI3CQFxK3 WhE1NmxzD9QafZmVPl77yVWOgHHqhQW0Pml5mQ1Oqxv975Tz9qRnqREep/Ha9kcowvVa 6zerviuAODyEyLDIyTtwr8xbq8Shg8RX+8oNFJyMoqnrF33D+hWpa54OLwfE46ZxAa5I 9Z5ciQBsyJFOA5SC4/iaRT/x7CF4jMpmoHDWSjmg9brpNeP6olHzMp/VXtffZMxHISlS /wmQ== X-Gm-Message-State: APjAAAXHdh4mVmm5aKgh8jKonasTTpO1toUOPgqDvO7nlsEXDxBGjm87 pFuLddvPOYHwPxF4N+dH+VG8UIBYFJA= X-Google-Smtp-Source: APXvYqxgBGm30wVL3Fg0yj0/bkAjzj/JjPbYbdf7cSShRDwHnFybGgczikuvizU0T7yq6k0ZeIvAiw== X-Received: by 2002:a05:600c:1105:: with SMTP id b5mr3843786wma.155.1568205413131; Wed, 11 Sep 2019 05:36:53 -0700 (PDT) Received: from localhost.localdomain (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id n2sm17050480wro.52.2019.09.11.05.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 05:36:52 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2019 14:36:36 +0200 Message-Id: <20190911123636.59733-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: Fix memleak when using single_file X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This commit fixes a memleak in the hls muxer when one uses a single file as output. It has been forgotten to free the temporary buffers used to write the packets so that the size of the leaks basically amounts to the size of the output file. This commit adds the necessary free. Signed-off-by: Andreas Rheinhardt --- I used av_freep instead of av_free (as happens in other places) in order not to leave an inconsistent state behind. There is actually no reason to keep the pointer to the temporary buffer; an automatic variable would be enough. Furthermore, if flush_dynbuf fails at opening a new dynamic buffer, the temporary buffer needs to be freed nevertheless. Yet this isn't done for the other two calls to flush_dynbuf. libavformat/hlsenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index f881bb9d60..a6a3947ac7 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2365,6 +2365,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) if (hls->flags & HLS_SINGLE_FILE) { ret = flush_dynbuf(vs, &range_length); + av_freep(&vs->temp_buffer); if (ret < 0) { return ret; }