From patchwork Tue Apr 12 08:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35280 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454362pzh; Tue, 12 Apr 2022 01:16:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQZhNJ6uqv0pKLYmZxiJMqM+079+etPCI3ussXXxxM2FPseuJ7jm7aIYj1iSrrUeHgqFQj X-Received: by 2002:a17:906:dc89:b0:6e8:73e0:ef9a with SMTP id cs9-20020a170906dc8900b006e873e0ef9amr12535394ejc.638.1649751381029; Tue, 12 Apr 2022 01:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751381; cv=none; d=google.com; s=arc-20160816; b=TLVK2dbiM7oqy0ByA1qpt4dI/jvvPa9RyXaJQw62I1w6f2PxhvpOfAYmtR3SomwXvj +yQ/ekmH66nbWHkW8w5pFz8h1VXZEP2a72AcVotkGWSTR2y3aDOigRc4yqmi8jQ+iwor OsDBjphUZSUdrCjbuaU7wWMQMXeFmrafpnK3wWcqEQpJY9BfyaNrxkgBFbPmHIloQ6oQ 1h5N79ZFLa7DjddazhWVcT8MgI9OqxQK+fZy6NgjPfbvBWEKBzY8pDC26DEdBqv0QbAM FnkiBPMZWi7pppkMmqPTshUlFuM7PnEiQuIZ08lFezier2KefhexHyPbtYwMctEDxntg 3Kfg== 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:date :to:from:message-id:dkim-signature:delivered-to; bh=5LCZ7uYWGKGSDu5RMcGuNlZExpaNwTbOTkd9PFcuqGI=; b=qROqBqPWIKsUrEFFUf0F+y3rJ30BV+9Hy0wZy3Ks2/Agtane9CgT0EhRJ9N8AW4dOs RsTq5vxX4RyCXI0R29Zvoq2NQ9Y0N/vpaMgtxnnrS8vg16C1zh9InPVXzc/wuKBbIUv4 iE461RLBRm0m5xkfWTaB0nFzlzuzTiIW+PEotCnKlY/HurFOrsvHPq+x5Riz4D1a2p8M o6Sa9mcBSTVT7DXb8iYPGP6fmOd+LhxJpvYuzNpPne5GEn197hECNfGmo5iiUFsTg5Ov noV2YQ5csw3lyxzl23bVxxaG5Pfyy2CaUI2HraAL/jBo4XoA1WJ5w6Mqv8UTuXdeU7dY f5zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=y01ADk20; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gj16-20020a170906e11000b006e88ce813casi4547193ejb.13.2022.04.12.01.16.20; Tue, 12 Apr 2022 01:16:21 -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=@foxmail.com header.s=s201512 header.b=y01ADk20; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64E4B68B393; Tue, 12 Apr 2022 11:15:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92C1068B370 for ; Tue, 12 Apr 2022 11:15:44 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751340; bh=EXMMaZbrv9I1LQjUEzAEwVCcxY03Cofaie9mIZhTKQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=y01ADk20aoKZiqcVQa2PlmZvNDxcgY7nuNwnqztK4uzi8IFRp389JT2tfERTtlqEC WKINMZiSZgFSHfFTGA7NHbsXNTNDuk8rJ8+Wdb6r/T3skxPmYnRl7dmpxY61/qXL5Q yW6p2gAvO20U3aJh4j5bqQKaVNn40el3t/DfflnM= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.68]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id 3E314CF9; Tue, 12 Apr 2022 16:15:35 +0800 X-QQ-mid: xmsmtpt1649751336t7d6o6x2e Message-ID: X-QQ-XMAILINFO: NqxKgsaVX1mSgeL/XMTSWe/UzXXHoqW8a7jBEDn9tZV4y5yxikZNEJe8XUgvVf iXKYeYw71GX1RsyJ4uimeOVqG8gnPwKjciPZ8yv/EbpWNiUQ2GQXrdB/69N0ZbzSpqJ/m4UZVh0Z m9RlQA8UdyhO+wxstZHwAA7of4cGrRCP1oNgvDrZCK/SmuJjq0F/KUhwdI85rKKzrx6Z48huUYTp h80x0hA15NHdPF9QhmMVgi4TxfCismGrtVVcH1/g7cMd9Q2P6WuuknWUl8yJUInGrF3nKSuspq6G TNRbntJvLSerZu21cHcsmMFrmjIoOjrJO/hJFSKfhqeCOXPNZn1Hho0RB61DYYwVy0r8eNhCFzk4 QimviQbNhFketJ5gNN3rDi+jLNQ1nuTr8sFSKoTc1JS27faxjMNAHAvaemYZMk0hINHsfxTz/zSY Ba4B4FE4vS3+dzw8P0NPDmiUGFbk02gMjJ7uB7SZIysMxsjBEB28uZA+S1Gb8Fo/mr9M9Pru3nD9 wlrV3zSUJb8eQlv5pa6QP0+EYUle1/Rdqm7bFxYAUSQWo5pHlNC5ELZ3t9LQqT1iDjX7M6PX7/2U aXv7BIxKGCHlHOXcQVDyuMr86bLB0Tz1ywGKKA8XfSKuNpnbdOu1ADCgtJCC05hB3f+aEeZcUcLJ bZrNQ2qFsHZwHK6qqHYFYM2Q3f5ZnWsKN1cf9WhPtD0Dl31GWzudlN7K0e/JNaWRMKxD1VzPr9V+ zFf0zykGncyT3rFpUtN1Rx28MIU/3DWhm3T4wPhOnAS2g6qokT4kDvwIwp75Dq6qMLJSfniVvuTA 5i9pRmn+jDrez72LC65x1F0zh7aXi9ZPN4dhXf7itLCbAzgaXuJx+MpLodkCT7gWuvUzfSdZMVd7 HeRVlbvDkSzA3Q8Ciq6vFqpzEi7LQJ7ArDj02362IcgcwOIaIqu71Nt8LXAC4pXw== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:14 +0800 X-OQ-MSGID: <20220412081522.43246-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220412081522.43246-1-quinkblack@foxmail.com> References: <20220412081522.43246-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] avformat/hls: fix leak of init section when dynarray_add fail X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 137UpwIRCmwp When av_dynarray_add failed, pls->init_sections will be freed, which leads to leak of all entries of pls->init_sections. --- libavformat/hls.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 67c9650e0b..e249810bce 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -463,7 +463,13 @@ static struct segment *get_init_section(struct playlist *pls, av_free(sec_ptr); return NULL; } - dynarray_add(&pls->init_sections, &pls->n_init_sections, sec_ptr); + if (av_dynarray_add_nofree(&pls->init_sections, + &pls->n_init_sections, + sec_ptr) < 0) { + av_free(sec_ptr->url); + av_free(sec_ptr); + return NULL; + } return sec_ptr; }