From patchwork Wed Oct 9 09:10:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15597 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 9DE15448CAF for ; Wed, 9 Oct 2019 12:11:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77C7068818A; Wed, 9 Oct 2019 12:11:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18E95688182 for ; Wed, 9 Oct 2019 12:11:02 +0300 (EEST) Received: by mail-pf1-f195.google.com with SMTP id y5so1221073pfo.4 for ; Wed, 09 Oct 2019 02:11:02 -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; bh=skoOSXQYjgQg/b30fH299CQg2OyXqRky1nfrQZRalV0=; b=i7o+GeFDUmio7knmSHrkgmZgVwbMh39yXmHiq0p+25jOruUxbNs3ZK31Wa3SuK0hW7 9Eeqe3xxJz+9lQPtJWOUkI7uqSx1BPiFr/Sno11yxQRqYHP5VieSo19EW6BQtG+WxnaQ PFZqg22W9QWALIsVb+PiAR6MuijnsCcRpK/D6CpISOMIWAoOj02pBak7rIUfi02imQ1o dSgDUWlPzh+XA/2cqGoyWhxuKedFrX27owsB+ocXdJVFNDuXejdoT4helSOiMTnoI9bZ 2Zs59dW8wEsKOlcKDtbXjATWrPPVr5LydHaQsKMmCh3cIXxygJ6J3HsLLhTCre6SXdBM 00FQ== 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; bh=skoOSXQYjgQg/b30fH299CQg2OyXqRky1nfrQZRalV0=; b=biN1DqCSKFnn1eKqo2N9O8sZi6yOiLQ7Y9B+OTZ9TcONIiUyNekE9FKpROdWWwBl4d KnNt+z4uLx9G4B70PXK4Gumr+4mKTrHylgLtNk2nKiqnyukqTt6vMLdM3rODbPMzqJjJ tUs0T1fcpBezg2NgbTg84GpPHluhw9QyvHJTP73K+pwlM1AY1XVG+HoMsYbQ7zTtM3ML Q9rTof52mCa2kX3icaFxlGnPh7ZrMTYsU1bAoTMAwuSQDo0mMr1kC0r1gbDpEneHKBsN HAjnogtfEawCY1gbo+SWhfftT4TWdFHVcCRhBimEInySqQo3+YuBpjDVYcNzqUHumrrU Y9CQ== X-Gm-Message-State: APjAAAUWRtn/PDtoPWyzJcJhWbNpH8Y2yJW1d5364C2yBbbHn6+f9gDf 8W629q4b5fx/oC88gVD43ZTz6rsE X-Google-Smtp-Source: APXvYqyXZoD2+d3yQg3RYoTHoUYeaBvd+08JfUGAIcLJa12VAZaUH6FB2WPetNksobQOZZ6tKO5FpA== X-Received: by 2002:a62:b504:: with SMTP id y4mr2624129pfe.124.1570612260162; Wed, 09 Oct 2019 02:11:00 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id u11sm2414037pgb.75.2019.10.09.02.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Oct 2019 02:10:59 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 17:10:54 +0800 Message-Id: <20191009091055.32508-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191009082826.31858-1-lance.lmwang@gmail.com> References: <20191009082826.31858-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/hlsenc: free the original malloc pointer to avoid error when system function used in the following patch 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- git format the patch on master, the v1 depend on other patch and can't git am directly. libavformat/hlsenc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index cd43201..3cdc468 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -487,8 +487,11 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, int ret = 0, path_size, sub_path_size; int segment_cnt = 0; char *dirname = NULL, *sub_path; + char *dirname_r = NULL; + char *r_dirname = NULL; char *path = NULL; char *vtt_dirname = NULL; + char *vtt_dirname_r = NULL; AVDictionary *options = NULL; AVIOContext *out = NULL; const char *proto = NULL; @@ -517,7 +520,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, } if (segment && !hls->use_localtime_mkdir) { - char *dirname_r = hls->segment_filename ? av_strdup(hls->segment_filename): av_strdup(vs->avf->url); + dirname_r = hls->segment_filename ? av_strdup(hls->segment_filename): av_strdup(vs->avf->url); dirname = (char*)av_dirname(dirname_r); } @@ -537,7 +540,6 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, } } - av_freep(&dirname); dirname = r_dirname; } @@ -573,7 +575,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, } if ((segment->sub_filename[0] != '\0')) { - char *vtt_dirname_r = av_strdup(vs->vtt_avf->url); + vtt_dirname_r = av_strdup(vs->vtt_avf->url); vtt_dirname = (char*)av_dirname(vtt_dirname_r); sub_path_size = strlen(segment->sub_filename) + 1 + strlen(vtt_dirname); sub_path = av_malloc(sub_path_size); @@ -608,8 +610,9 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, fail: av_freep(&path); - av_freep(&dirname); - av_freep(&vtt_dirname); + av_freep(&dirname_r); + av_freep(&r_dirname); + av_freep(&vtt_dirname_r); return ret; }