From patchwork Tue Apr 12 08:15:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35278 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454252pzh; Tue, 12 Apr 2022 01:15:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdiDIYz9FNWe9uV5nn8SZE+lYXkNtK+p0s6PRxw3yGRBCuElRc1k11qwunssoQk20sHDD/ X-Received: by 2002:a17:907:6e88:b0:6da:8f01:7a8f with SMTP id sh8-20020a1709076e8800b006da8f017a8fmr33839471ejc.619.1649751358120; Tue, 12 Apr 2022 01:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751358; cv=none; d=google.com; s=arc-20160816; b=fAZ7VomdDwAlbqc3LdT2h8PDxEtL9kzDnQgC/PwRRON0whtzYAMasJj2fgzXywShsO Cwmek5zdXb8VhMWo+BQ+X6WsBqQwosGpBB1W6p+oZGEMCwqkQekql58YgqY3XhynchmO rf+b/ID8+oZFB08jL9JOs54Jp5X/N9HiKweHG8KnJXqAR4S+eLN0P8U48n7PbTlOl96l TNksxTkvQoxwwW0PkCvPBVEdo0mKg7ALl0SH6hvJb7kpsxTAPpBb5C8Kr9rmvU4ov3Ct zpS4MQlj+NDyBxIEOAsJmv8B15x5neDITQgOullu3QgFdp4RUxixutxrplfmFSPU53ff Cg5A== 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:date:to:from:message-id :dkim-signature:delivered-to; bh=A7Nu2rZsZQL7yAF7okpntgrGpWRLMx0XE8AZtT7SVcM=; b=zuDg93JyX/8yKHXJJsm6JIGpPaVaaQZXzCx2uDGgAQ5O9osBPtny1H123SWD7aNYJd 79LgYQXeB1GiFcEmzJ7YacvJYUaEmFKdkJkHfxOoGRbc3n/nwpp/A0N0HUP1Uu4fX8Is FO79IK/Q65LjyRZphwYaHk3ueMBJB+wS1YjAzyAERRObLjpSOBryh47lUNHgldUmVLBg AAj+P8WSLHQ6Ji8vbpDTjYOhLbo7gGyD8nwEfr9HQPp4zKuaO+A0zhKWG5iGax+WtG3X aDwjeYJbohcRd/Df9lqsGuO5IvS7yE4U6QU8PI72H0ENLP9YnYFX/gGKdFVfUTfFUVke Muvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=ZGE96sQJ; 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 bm11-20020a170906c04b00b006df76385d9bsi8402079ejb.571.2022.04.12.01.15.56; Tue, 12 Apr 2022 01:15:58 -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=ZGE96sQJ; 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 15E6E68B382; Tue, 12 Apr 2022 11:15:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-221.mail.qq.com (out203-205-221-221.mail.qq.com [203.205.221.221]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E894568B370 for ; Tue, 12 Apr 2022 11:15:42 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751336; bh=xvYN4AveD0wkK9kbEi9953kcWFSiiXYy7Xn9Q19TNF8=; h=From:To:Cc:Subject:Date; b=ZGE96sQJ9UVO7lc5Dws5ZFrbLjNGe/i6FirsRnfoFia/CTPCKuPwvght153/5P5W1 ElVeYaQr+QJfdDwwk70OVLX2rhWnWCG5sUbkbEf4SdpU6n2se2SPgN5LmkjzDF4eKP q8PK7Go7HnAkbEV6v/PFG6VMw2SPBSGArylhjuDI= 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: xmsmtpt1649751335txoae7y1k Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjm3Ewc3sGagZq8X4QawDMMgAzzK3tKPkxhiCp+L5JPvrgyEp7iS h2SCQs8GCqwfW62Zxis5VNNjrpkJU1gWHIXOlh3lTQ3eNDrHgZQ4ZzDjSE8q7zghz+1gA8JcNhhs prjqAElcS/dM/TFdtUtXygpBWgmWX6wYgWVIkF0StgQjRaaAeuUIgcKmT8UBqTtxsMvfG9M5WBlD IBv4Vglb4KANEoIaHFAzxWNxRzyngHtoeV7Bw/GDFMV1jF6IoMOGV6y4Onnq6VtRrh7Cz8szMnIj y5t7cOwo6p3ytKLON1BOe843rL0odIBRrAsJykedaU1gSmJfHQcLj6f5KWIuuIF5NILLNBFN+EHF OHtmdL59u+5cWhAsMIwXy5Q/BNGc6DKNMPVkk1KCHkVaLjjMD/bKI6lkzq6dEvOG10w51iCCDlxT a8BFMXwAR+FMcxPT4i9AM0eYFROTWTaH13X1xrm2hBPEOZtrTuPp3QGExZPt5gDkA/x2K0QqQb3I K4V+auUSpneBSeD7qXzNDXu8T8H4yto2dlzPEm0yzmlEDYORrK57FMouXf+ihiPXXrBIF2cMW0fr BivN1oVHsvFaaMUuzhkwMJA8mTi36eBRbORT8PMVHqGw+jBvlTN/yTDX5eUIS7BnRP0gOu0Mu7dP liNkzPClN5yuvtNTAooOdfCDSTXyKNCimkJAYgT3HMdTZN59mWPI19Z/C0C+fjW1NeKtlJ10iQRt yefE/Ce4RsuZ0MGScFPPyvPvJCcOhFYX9WV9u1LF4nrRVAhCiyppgZGZQNug7fk9Gj2yzvk7oVkN FzSczvV+ETxlfzErqfXinLjlWWoxx2cstVIsrgdfmHHqVOYJuPES8lGhhHiNhk+avQ13DMwIsCdX 4b7uQwket3oKMxZm+/waqzQuY/nHIykrJqroYZuvjjWy418Bd1MmaNmBWTPCGHKQ== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:13 +0800 X-OQ-MSGID: <20220412081522.43246-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] avformat/hls: fix repeated requests for media init section 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: 0u3Kfsa7ID3n --- libavformat/hls.c | 59 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 83ff4cc607..67c9650e0b 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -407,48 +407,65 @@ struct init_section_info { char byterange[32]; }; -static struct segment *new_init_section(struct playlist *pls, +/* + * Return a new init section if info is new, otherwise return an entry + * from pls->init_sections. + */ +static struct segment *get_init_section(struct playlist *pls, struct init_section_info *info, - const char *url_base) + const char *url_base, + int *new_init) { - struct segment *sec; + struct segment *sec_ptr = NULL; + struct segment sec = {}; char tmp_str[MAX_URL_SIZE], *ptr = tmp_str; + *new_init = 1; if (!info->uri[0]) return NULL; - sec = av_mallocz(sizeof(*sec)); - if (!sec) - return NULL; - if (!av_strncasecmp(info->uri, "data:", 5)) { ptr = info->uri; } else { ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri); if (!tmp_str[0]) { - av_free(sec); return NULL; } } - sec->url = av_strdup(ptr); - if (!sec->url) { - av_free(sec); - return NULL; - } + // Don't dup until make sure it's a new initialization section + sec.url = ptr; if (info->byterange[0]) { - sec->size = strtoll(info->byterange, NULL, 10); + sec.size = strtoll(info->byterange, NULL, 10); ptr = strchr(info->byterange, '@'); if (ptr) - sec->url_offset = strtoll(ptr+1, NULL, 10); + sec.url_offset = strtoll(ptr+1, NULL, 10); } else { /* the entire file is the init section */ - sec->size = -1; + sec.size = -1; } - dynarray_add(&pls->init_sections, &pls->n_init_sections, sec); + for (int i = 0; i < pls->n_init_sections; i++) { + sec_ptr = pls->init_sections[i]; + if (!strcmp(sec_ptr->url, sec.url) && + sec_ptr->size == sec.size && + sec_ptr->url_offset == sec.url_offset) { + *new_init = 0; + return sec_ptr; + } + } + + sec_ptr = av_malloc(sizeof(*sec_ptr)); + if (!sec_ptr) return NULL; + *sec_ptr = sec; + sec_ptr->url = av_strdup(ptr); + if (!sec_ptr->url) { + av_free(sec_ptr); + return NULL; + } + dynarray_add(&pls->init_sections, &pls->n_init_sections, sec_ptr); - return sec; + return sec_ptr; } static void handle_init_section_args(struct init_section_info *info, const char *key, @@ -851,13 +868,17 @@ static int parse_playlist(HLSContext *c, const char *url, else if (!strcmp(ptr, "VOD")) pls->type = PLS_TYPE_VOD; } else if (av_strstart(line, "#EXT-X-MAP:", &ptr)) { + int new_init = 1; struct init_section_info info = {{0}}; ret = ensure_playlist(c, &pls, url); if (ret < 0) goto fail; ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args, &info); - cur_init_section = new_init_section(pls, &info, url); + cur_init_section = get_init_section(pls, &info, url, &new_init); + /* Skip if it's the same init section */ + if (!new_init) + continue; if (!cur_init_section) { ret = AVERROR(ENOMEM); goto fail; 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; } From patchwork Tue Apr 12 08:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35279 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454311pzh; Tue, 12 Apr 2022 01:16:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+TjwnBOk5AVTltNOXccfP0FHkd1+eD2kaKXVAaFoUaEljGKXbkmUM5QbUDH2bqYe0cHDT X-Received: by 2002:a17:906:ae85:b0:6e8:76c2:1f1f with SMTP id md5-20020a170906ae8500b006e876c21f1fmr12729817ejb.333.1649751369747; Tue, 12 Apr 2022 01:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751369; cv=none; d=google.com; s=arc-20160816; b=0LEh1oKl+ddyuvWiBBUc6R4JWVXRVSnBt9h9FCNvEMxfzzHdD1kcbxI13/LO5wC95M st3cUMZ3E3XGhM/7u0ucWzx7bdVSOWK+13MKMUHZxAsMfvw5D3CTO+5Hu/uShqg7W1xU yI3fu7TbnR2KUxpbXc2bGezGeWFslzLawZIathSpYNcMtyqOWkrInIpaLO8wz9hMns0z LxGvxsFHR2Ai0vxNaM6ywa40cq/GEhXRUyWver3xE1rAizsLZ/atBmR6D++X5s0TjA80 NNaRuumSS+asQEv2b+8+KcrXpimugNSpE0f/Fxr88XW/8PhdwMdAAZGClv7ir8eLdfVF aoaQ== 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=BCKkKLJdA/zqYE+wUsSP4q66OS2mJO0ttk2O3k6YCOc=; b=rbVVE5OqlkY4//L8TUJc+wlq3ZfIWfGgbG7mw2PdxA7SAfkR8J/gJIg/+aqgDDuBMC PtEG7JL8gfHliJP+nwiM+Ssyvh8zN1VeyO0k0XfGjl0PudPkSquxQU5ObQNvhtdmwJ/T 0yjeDfdA2vvU1RgsH5WO+H3HDPk2vTjNVftEs8L0U88hWoR65M5EMDutmir5UqUkt2Z0 nV2RQRnBuWDOLKfRJlsH7L2j7bvXcWyO54/ffREjcU+Havi1sd2frhtm8sWdq6rImWtG lnNMg8+sP1jNOKhijVHr/p5S40StK+A75B/QJTEzXP6vIUe0xUYxooMBisjNicYem/Ig LLAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=iO9STkE7; 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 e7-20020a056402330700b0041d93f87e93si806144eda.377.2022.04.12.01.16.09; Tue, 12 Apr 2022 01:16:09 -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=iO9STkE7; 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 4FC8468B399; Tue, 12 Apr 2022 11:15:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB99868B381 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=1649751341; bh=DGGH8/zjMkG3Svtjp+A9/+DkAUuJbvNATnRpWKT85qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iO9STkE7Kp8kYijHYkqxuXzZVbHU+Khstrq1i4tYkzx3g13uqsAGZRv4OGecIUbeq YzLONZg9+F02J7lIUl77nbyRVmJz5BaPNsNU5zJwmt3Hl/i50W+rcD1BQJHY81eYWD IsH7sa2l9dqK8JtHBE2+4hPvcEOMnItaIzgcoXVY= 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: xmsmtpt1649751340t4iwuh53o Message-ID: X-QQ-XMAILINFO: OBfNkvzAyASsA1A1aNrbAqjzhdUBlRh8Ca4f8USpl5HRfi3gwwOmCD0zp1uDY7 n20a1XblM8kYuifGIBtvK5pC9mVtMr6zNNhQ0yPy9Ra7j2xTlylJzW/+03VLeiuOmodzVBeghgxh 5qLCV235SSrUVW8WBpW7usyHyllYQhVzfiDbNplFqQldmqK6ayB9MP2buuG8j+hrMXVXq90iVB5e AE5KTUn9oUaDa+PkJAdhUKxMnWrZBIfOXy0vHXiGZFWXifSrmgmgdwDgBS/hnfSsY90Jj8sTs672 RL03tFbHKnmcRy5im5E0/e26o8EIq9sdGE952eUJV4cj5EjEl/aJj3wxgew4zXO5t7HBdkeBeQbs l7v3R1qMy5/aVdpQ1dGGtVTKYs1cD6f2w8Lj0AtmiONt9Ds/u20Q/QlUXjudvS3bkJVRUXD+qxnf /Ax31xXWOD5MNXB3f26zkSQyxSmApswMevLKZytuuAhaQAmfwkzGmkJpHlvLtExUTwa3bs37RtqR LWDl5jh0DhVVQyCtH1V1sHkE8fK4C7cOJ1qMBl0UyLko5xAPYBhOT6+eW8s1EkePnZ/newBFBNT8 DmA2VC3yF9La2v1UZ8nBGqt8XwP0ukUBzMZE1dWHS0p4/xON2DuOslbG5Zk/uS93y17DQenWABv2 5IZnu048bo6mDYyy2Nvn58u2m8nk5fH7yqJg9+ff6GMXw5h0VqdN87dv7J/4WUjlYZmSFaMlovHY HkINDqYUri6TUQ+0wEORtuBGfLC++88cmjciV/wZWpsZLJEK46PHiVHMna/bnEy5PTB4opX3AMnJ p8GvGrpNR9Cyoka20i24WDX7ewaoKjSGCKHbT7J9APxxgYzOY7zfSsdWwm0O8dAWMuLbD2gQmtz0 1mcnPMZDue/uzpH7izMQtn0/Wi1JCwjAsJpJ2OitoY1ua+m5lL1NJYGMO4GXVomknA+9RwU/vq From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:15 +0800 X-OQ-MSGID: <20220412081522.43246-3-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 03/10] avformat/hls: extract free_playlist method 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: CeRxtx0+amqJ --- libavformat/hls.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index e249810bce..ecb6237d2e 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -253,30 +253,35 @@ static void free_init_section_list(struct playlist *pls) pls->n_init_sections = 0; } +static void free_playlist(HLSContext *c, struct playlist *pls) +{ + free_segment_list(pls); + free_init_section_list(pls); + av_freep(&pls->main_streams); + av_freep(&pls->renditions); + av_freep(&pls->id3_buf); + av_dict_free(&pls->id3_initial); + ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); + av_freep(&pls->init_sec_buf); + av_packet_free(&pls->pkt); + av_freep(&pls->pb.pub.buffer); + ff_format_io_close(c->ctx, &pls->input); + pls->input_read_done = 0; + ff_format_io_close(c->ctx, &pls->input_next); + pls->input_next_requested = 0; + if (pls->ctx) { + pls->ctx->pb = NULL; + avformat_close_input(&pls->ctx); + } + av_free(pls); +} + static void free_playlist_list(HLSContext *c) { int i; for (i = 0; i < c->n_playlists; i++) { struct playlist *pls = c->playlists[i]; - free_segment_list(pls); - free_init_section_list(pls); - av_freep(&pls->main_streams); - av_freep(&pls->renditions); - av_freep(&pls->id3_buf); - av_dict_free(&pls->id3_initial); - ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); - av_freep(&pls->init_sec_buf); - av_packet_free(&pls->pkt); - av_freep(&pls->pb.pub.buffer); - ff_format_io_close(c->ctx, &pls->input); - pls->input_read_done = 0; - ff_format_io_close(c->ctx, &pls->input_next); - pls->input_next_requested = 0; - if (pls->ctx) { - pls->ctx->pb = NULL; - avformat_close_input(&pls->ctx); - } - av_free(pls); + free_playlist(c, pls); } av_freep(&c->playlists); c->n_playlists = 0; From patchwork Tue Apr 12 08:15:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35281 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454416pzh; Tue, 12 Apr 2022 01:16:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrg7BngY2foqGakFJzyB8PgCqkrnopwyYYPQAekMzaosqk9CH0RJ1UN68BjQ5r341fyhis X-Received: by 2002:a17:906:7948:b0:6da:64ed:178e with SMTP id l8-20020a170906794800b006da64ed178emr34797185ejo.523.1649751391505; Tue, 12 Apr 2022 01:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751391; cv=none; d=google.com; s=arc-20160816; b=FcOYcIaPjai6IShk3XS5JCmznDUYvnCL1bYJKmqIf3cStZ6U2jXhDbevY26cHgAWsd g15sVLaMw4Etxixo4yc+WJqUQKbBcru+G7Ub9S8nhTN367+xUwEraj2tfsaQccoYXpkD uwMikUpA4RPVsr4FAyoyue6HHp8P5BZXq4qiinmKgB6u1PuZF1v5eqeKFoW1ujwY7QK9 GrxfvUFGvkxFMqV++fD5LRDjFV+RnUpGyAEy59J6rrGlogvORJ4/e8+Q+tRLoaHTg8lv EIYdM/T9CL+OM5AnEIou5/1uZcFLUQQbgv7kvs/A3vMC36h8jgYJ00QTTkuQ+aaDUUfn Nc0g== 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=MyxLf+RG7qSWPxL7zmvsLIf3B7r94UcPAH62lUNm+xg=; b=IQszhTFXjqLVvs0iwwbtJWia1lkqEqBBGqsy1zzyd+PLmR4gKgtLUOFo+SMrc0O9QV EAope2cUPxAuMqEAYHRGJpudq6/grJvhyxBGMgKQFtRCN7eoLpX9ImIWQvUAWZmMltB4 ObeSS1xirAXAqvxkml865Gao+crlCR2gNUQ0XVRMfsr985uzJJoAjJ6ONrJIaqfgIqw1 Ptntl5+ZFVx3i2wSKUGmgEaTK/KqIALgs2HMRNpTGZ7LECRmlbvFip09A43esRxJnfB5 ZlyUcVkoN/OcDn/emkmb2qUn3HpEJN9Bqra24hAsFVhtvPP/Gu0SSsJII2WVl8kL957j kFnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=GbDtLJ3f; 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 w22-20020aa7cb56000000b00418c2b5bf16si8111231edt.504.2022.04.12.01.16.31; Tue, 12 Apr 2022 01:16:31 -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=GbDtLJ3f; 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 4FD3368B388; Tue, 12 Apr 2022 11:15:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-53.mail.qq.com (out203-205-251-53.mail.qq.com [203.205.251.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9AC1668B21E for ; Tue, 12 Apr 2022 11:15:45 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751342; bh=45Zy7Y3L7QKqYsPDztR01l1mwDePEI55JbDjO5d6P7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GbDtLJ3fNJNARFBTswmJspTt9zMjQPU4e2H18pFAnogJA19Yvd6KSpqGUjZ+NJnZ4 JtAXXP8iRKtC5HYgP72Mh32FOaTGAd8ZpKgVgkxyhlCsn715H7nEEm9AISqiycHBlF P4a6tr2YGgWG0FzKIBPksYH3B4mlKj4++sj5IlPk= 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: xmsmtpt1649751341tmuijrk91 Message-ID: X-QQ-XMAILINFO: MmCmH9jyqHC2EOW9AyDqpg1e547gLnZhioPgpkamv2C0h0oxQdqtTF4HDCsA4i CmL9Q+SDDNLhT+q9ZwJe+Pv2iAFnQtcsPoSW7iJkBavkFF+WlnetfQm676p9HYNiv73XxXtJw8lO WaampsZu/L6QauXQd9pBm06rC4sZkne+jYInOija6gcGPptEtjnm1A7glwxgh+Zz3IbEL/FB2IMw TgKnS+JHFWQ5Omd0LFA/QCtlRxzxZD6Y+uDA4h9qoCDTXIPMeR4sc14Dgso7HZEoW/3ICg8duLnC E8xe54K0AjRnYyq283WK135SJj0/qjQImapoIcArmFQ6tYghsCSGaZ7Zov/mZN7bCtOzYO2ia6PM /HR9aAqRFLCq7VX18W+/C7+G+nl8L0O0yhT5imDy/p0iwhTGDe9/GX3rX2d8pJUFgmgMzYddxMfh Z7zCI73eBdV0fyYEEwzgcIRCvnM44n3Rw7cAHMbp538KTtDpCoQ5ok8GoOi9rQgrZDKJEoqb5CDO IePSmkS+VsBAk1L499r7KtSSco5KurW15wnwQjvcETYZgjeBS55UTIukRaW35RGT9S8BcMP3Y6ED +dSeaBnt/2y+aJEpdrYcJnCJ6GQOZXEX4WVcZKfz59Gyob451/Ir4eZLVSoCmorLUlUEVNa0S+11 8SKUB0aNNiQ23ZU+wrhbuKMQ0x1VimsI87rPuVvKTPX72Pmx+uDITQCIVE1Jsj4zj3mlkWISSS9z uqjB9zI1fG9YQy8MvOJysRkjYBmkCqLuPCC5KCbdiynN70tmUpP4/MSPjUuOkH4kzCOdKq5bSuDF Ew71nGYa/CDpN0ZH1MZHcRhnkGJP6vMHzmbpCZ76ZzYY0ToKTRmYsW/auVaP+SAtSNq0uJkL2HON uGDAYPirThM+Y1M3iT1sXGdgydAUWDo/cL5Zmz5DZfTCV1mtohK1Wp5GdQyYlaVHK/8IpOD43OC8 heoStjz+7OFHeRQgGFAQ== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:16 +0800 X-OQ-MSGID: <20220412081522.43246-4-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 04/10] avformat/hls: fix leak of playlist 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: +WunmLYZhsn4 --- libavformat/hls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index ecb6237d2e..d5c3009d07 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -330,7 +330,10 @@ static struct playlist *new_playlist(HLSContext *c, const char *url, pls->is_id3_timestamped = -1; pls->id3_mpegts_timestamp = AV_NOPTS_VALUE; - dynarray_add(&c->playlists, &c->n_playlists, pls); + if (av_dynarray_add_nofree(&c->playlists, &c->n_playlists, pls) < 0) { + free_playlist(c, pls); + return NULL; + } return pls; } From patchwork Tue Apr 12 08:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35283 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454528pzh; Tue, 12 Apr 2022 01:16:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+8C7oSjGd9Vf9hGmRdd/dLCevVe7AzLLcApsz1/9kvItAAnr69SS3cFGqVZLwuaxMxfL4 X-Received: by 2002:a17:907:160b:b0:6e8:58c1:8850 with SMTP id hb11-20020a170907160b00b006e858c18850mr13733448ejc.284.1649751412988; Tue, 12 Apr 2022 01:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751412; cv=none; d=google.com; s=arc-20160816; b=XEQfFh8dMiaYfmSZwh4RyVS/TBDg2E2uDDrxPr97Olhx2smrh0sA+he6+5cM2uqpMu bzcEVf81+7Iud8LvEre0dQWnlgTmDZl1y46/PlZhsDNY2FSfE/M3TlTjBJQrZ0R1COZS kia9bCORlp12qwJry65yNw5mxVxSMRqnb/S2sM6cRcrrLw61JmxHRgsuESQMp+A3hwdB 2H8nExvZ5e3lnVu0Mzf3LkIuVuouzXKknbkteV7WJQ1JwgjwVnAwJNa8eHEaQfGu4pki I8wFtrRqsRuv0cw2pn2/BtCnVB/clEUbbIKY+DI1isVpp1c13RpoQwXizHeCuOsFUa3S pQVg== 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=uhHSy09l+Y6Ve6bYYGOnQt0I6nEVMXUA9P0DPYXp1mo=; b=ovrLCfGcMIZL3Vdrd9q+OcvOgCjFu+qnBz8ZEbT0WHBj3vwX5LuYgBooqsoVTt4wSY A9IjvioLMx6/JVduAALeXxCRLn/x6p3PGTTFO0pyPzy/A/7P7hM0lgKMw9/bt7ZSDhbK OgxSrgQPjXcEXg7bw7u9LFviOnQmCl7FWJnm6OYei/mTjk1ouLHb6rIoHUvB5cgpTaba 439ft+i5p9kafT4289eH0Ggx1YBWbXWV9u8RuDk7ziFo/AA+pzzTWTCUi+key/bRmrwj CQ+L+yl5748hdMN747YMJ4d1hcU1CL8+E8bpumlv40QGWySAQ/CL2S/T6XjVB/9B8c3Q /oYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=qJjckmtN; 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 d10-20020a170906174a00b006e866549c5esi6942216eje.702.2022.04.12.01.16.52; Tue, 12 Apr 2022 01:16:52 -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=qJjckmtN; 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 6571968B38C; Tue, 12 Apr 2022 11:15:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-60.mail.qq.com (out203-205-251-60.mail.qq.com [203.205.251.60]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2135A68B388 for ; Tue, 12 Apr 2022 11:15:47 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751342; bh=Z5hsxg+uMpOmEMYTMHzexyKVJ2od3+PTj4IX0O2ktOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qJjckmtNHO9EtucaHNjyCe5CrR4jLby7LvlpQrum7pl1rVzrEUpxi3fa+flwE9AQz 9k5q4V3rai5sqcqJAo8cXztQvvc/l9/6s4P/JEBXViZeGyr9oniYO0DIn4hg8kq0Dk Lp+R9rrRRIZJUwu2Q+jY1ZY6dcfbPdeR1lsYnJh8= 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: xmsmtpt1649751341th2vkz059 Message-ID: X-QQ-XMAILINFO: OEgU9iHXvJ5FDbDoX1uiaACfpt32Dp75Cd1G7v3cD+Wln8gyI3bwH2eFDyS0CG Az2sfX8cxX7Zg00IGsS2vOX7hZaHiWd7NA47Z23qYdzk7wH/gHyVGkByJivz5DnFJ31QgtKRwec1 50JuaOpz8ObxSshIjwruYz4iGFTv13fXwkTlbSYOanmB7a7N3OrxO5gd0a3cHnV6URYxGyL86oMV grBMy5Y9nWJo0cc9K8cLMRFt8K9JmVtC831ctBYN7ijyc++qGkzZG3v4itFdB8kdpfAgVg2Jcr07 rtEBvfHaFkdH3BrosgPOJaPt2VGaRQgLfPZ6VJalvLvLGTiZ1k1NsWEE7PODZpkRsPRNzJrMO41T A956EAeXv1pDfHFS4WuizYJYz3xkJbhC5o96daqQrYIDtKZw31MS1JkiwK/2s0lAT3aR7xdPUMy+ CdXtv3Xd5gHgkYOVaUA1ZfX+mFvVALRxhVYkoAzzfDcJ/SN2Pp3LBGE06VFj1lfQQhzBaKyiYHIK VKdsY8eGKGCYhv8uo9YOqvSapFS/4vngnxcNmDiph2SL8LxJdIaa0tPUkiBI8TvNmULLNDvtngtJ rx9iogjU4tIKgzJiNrcZSVPa/VEAaHkBx0+ZsTIF2EtXuZ1yQrBHfPU4VmLcc/RC3a3kSjwEQ4xb fOoi8o1fI1/P0NmYWkb4g3ng+hVHgh2DUh5rlJKQiS53osIgrFWhbjV0+uO7nZjQxzYhIHpQTbMJ FqIG+Iy5Q549cxlJocnnoq3wlHxopG4xfGqZ/bUiClHpXv8hBgxJsC+9ZiMKqF748iAHiBNhXFxw YnW24jg4BbP3g7jSei8FUTcFiCmnXICeFzF6AVA7P+cKJUMsgwK3TDslnwLmGO1J2/j/bl4AlAtq c+fS4rzpf+JQWRtnRGiSWPk4n3JNuC5DQ+whqRPbjc0xCXeFeJKNDZY8jsgWqqbPqAdH7GJz2jSv +CfNyUzoLVDI6kD8GqwA== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:17 +0800 X-OQ-MSGID: <20220412081522.43246-5-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 05/10] avformat/hls: fix leak of variant 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: YVXXYzQrT8SK --- libavformat/hls.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index d5c3009d07..b5cdf158c6 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -366,8 +366,16 @@ static struct variant *new_variant(HLSContext *c, struct variant_info *info, strcpy(var->subtitles_group, info->subtitles); } - dynarray_add(&c->variants, &c->n_variants, var); - dynarray_add(&var->playlists, &var->n_playlists, pls); + if (av_dynarray_add_nofree(&var->playlists, &var->n_playlists, pls) < 0) { + /* Don't free pls since it's not owned by variant */ + av_free(var); + return NULL; + } + if (av_dynarray_add_nofree(&c->variants, &c->n_variants, var) < 0) { + av_free(var->playlists); + av_free(var); + return NULL; + } return var; } From patchwork Tue Apr 12 08:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35282 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454474pzh; Tue, 12 Apr 2022 01:16:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW5FDqDcvH1LTdG0tDvAr7RAxFXN6Z0VRymEORkdkeoIFagKWM098qqYrRDIJECpVoRxlZ X-Received: by 2002:aa7:c6d7:0:b0:41d:8afe:4a6a with SMTP id b23-20020aa7c6d7000000b0041d8afe4a6amr4401294eds.281.1649751403050; Tue, 12 Apr 2022 01:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751403; cv=none; d=google.com; s=arc-20160816; b=r7LQBj2kBqXA0L1b/Y9HCWDA3rbRbIBkIjhNEa8x71sSYmFWzp0qCfaIC6JqOUWM3w mnchewpfmzu1qOEXk4o+FMaUFbxjXpE/NLRXFz3ZYa1w2OjblhqezhOqs9A6CNnsygWn RnPuYHTKc9PHWi4XrpfjuAjnC529acUvfQ5AHtMPdW8c4BEDh1jNe6yo34slQNuEjPww 7eJ69TQVSbliv+/2xhR/reikvpJngkW9U+EXGJSiBaMfuB0cX7Tw5DP9cZwvVEi+K6Q1 Xk23cspaTE2cJypybj6FKvMzKmsLi7UaD1g/ACaziVh5yySsBe6IheUe7BGiCU8dK8n9 se+g== 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=HolNPec9703hTmZLLVq/gDxLwvu5u5ZChZSZwxG6xhE=; b=Kil+/VwTYZBxxQ060W5oOLmGyHt8+PFHowvWc8iV//wUPbPqmRPCmLsAgQPjZbsGj1 q4cHfP2dC/sE3LQ8DI5JID5AWhX7KdtUyvJnQVw9gJ7SmA6xX2IN4/fK4hrf6R1Sq4V2 g4ciB0/UoQvS78RQZuJB7bgNea50wwVsRdn6gleLsj07YzcSghynNmb0OzcUaAoPwH16 XMOv7VAqyS8iMj6SFaM9D3U/3rk77Mqd4WT7q8G+cFHqtuJfBknXuAaLl1/oGBrrnazw 0Cp59132oQ6GSoJCOW9TNR8Vg5/jT9sPbnHoPdqMHedfYCkYc1TbeuVFWu2nNCSGmpSV vvhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=fT+i6mrI; 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 bs12-20020a056402304c00b0041cdf19f8c0si8278351edb.569.2022.04.12.01.16.42; Tue, 12 Apr 2022 01:16:43 -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=fT+i6mrI; 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 5F92368B3AB; Tue, 12 Apr 2022 11:15:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A407368B38D for ; Tue, 12 Apr 2022 11:15:47 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751343; bh=NYi5o4YbgqiQC6n7DvJB9ggnZVmwH/P1gpUc2+C03xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fT+i6mrIKH95LucHLPUUj5tXq8zut37eXTK2yN/W6pBjwGgEnmY+1estAzb3dZG3n bsXQUk/usU2fQuJmHv9tuuIHxP1SJ6ksdvgOtS7uOX7+t/edg7d1r05lIQDmLH0XV6 dyL6zrJg3pCy9WC6M/LW72ZWl5ynNit9F8gYNPH8= 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: xmsmtpt1649751342tdoxm8cvv Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjm3Ewc3sGagZq8X4QawDMMpl3KhJ7esYKYiJP66MGpACOStsu1s 1ItKfHz++FqFrqYDmRfHZhD+hkLLbFM2cyY3MgU0XTGeVVm4kWcP+ur8hztr8J26UUk/N4LgekVY CaXXJnRzmksdVkPW9G4nBgZy4BOZbWLz/1uk+2zxQbNXZ7I6FvM1FgrBJjmYxhtfUd/RyZ3c3j7c PrCBfe44TL4uKVnnRld7qWbMd7BglwNKVKPetFYRFCgURKQXy4jsZXV5rBhGTKouevED4FVj4Tah GoOGyu5yO3/0StQSk+6HNImksa9PQs7mKkBEc8++IpMxV/XNKRGzGRqnE7uWadUPv/HFa5AETP12 ++hJC6uBivGmZJbcXc27gWlw68I40USaY66KDoSKUV2TPsm3RpwJcKbiWDGR9me4CbKp8O0fN2PO Yg0cF5D9iO7kXB3EFaX9dndjAtHVZTjxs9n1RZie5F+NjN2m15FxU5P3GGGO2VC07k4iBiRM7hWU JtDXxcACL/zqqNqSGp8P/nhmwk4zXsLzi6zjxc1x5b0+qkKH2SYrjTu8/7nKKpm0YvLHV5xibbO2 /a9hu9h92d62bIugWeiqt0DpYful32CGW3VIM94P+aMkqraE9hzzpjB4/hCIsNNjDVVoGm6kG5P2 mOcDVWvrT+XeAgOiU+OvkkaULwXKVIKtckBMy7rhYpH3EcIgM1/JglN/uYw8ZtM5PXEdfs/MGsoj +aKOFzi8k0n1uoTdzojtBpmQUtC8zMvy1mFSHOuPbxb+A7NrTlPp17Evy6pLXlPC6A6U9hYZInqA 3+vzHMBX9VAeD0Gy2NDyHu2E07elHIFdlfB8cSBmqjuyuN8gX94ud+8IitB1pqEIK/jcobydF9Km A1sECvwUDODCiif4RzpDebS9/0+NpJD3poHFmWkgBzb+kw5JS2Igc= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:18 +0800 X-OQ-MSGID: <20220412081522.43246-6-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 06/10] avformat/hls: fix leak of rendition 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: h32xK/2zt4i0 --- libavformat/hls.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index b5cdf158c6..3ed6007d0d 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -556,7 +556,10 @@ static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf if (!rend) return NULL; - dynarray_add(&c->renditions, &c->n_renditions, rend); + if (av_dynarray_add_nofree(&c->renditions, &c->n_renditions, rend) < 0) { + av_free(rend); + return NULL; + } rend->type = type; strcpy(rend->group_id, info->group_id); @@ -566,9 +569,14 @@ static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf /* add the playlist if this is an external rendition */ if (info->uri[0]) { rend->playlist = new_playlist(c, info->uri, url_base); - if (rend->playlist) - dynarray_add(&rend->playlist->renditions, - &rend->playlist->n_renditions, rend); + if (rend->playlist) { + if (av_dynarray_add_nofree(&rend->playlist->renditions, + &rend->playlist->n_renditions, + rend) < 0) { + /* Don't free rend since it's owned by c->renditions */ + return NULL; + } + } } if (info->assoc_language[0]) { From patchwork Tue Apr 12 08:15:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35284 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454578pzh; Tue, 12 Apr 2022 01:17:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5xqc/i1+8wiuR4FOObRh4TAAP/F0k7/HHPy5xxWEYuz4bDdHGGWAvT8/uQjMgcagUleOq X-Received: by 2002:a50:9eaa:0:b0:418:f708:f59c with SMTP id a39-20020a509eaa000000b00418f708f59cmr36943132edf.333.1649751423709; Tue, 12 Apr 2022 01:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751423; cv=none; d=google.com; s=arc-20160816; b=kcPrIKo5lpv5Si+2mfSPh2pBH/cTq7ATyRPUt11GvWES5YemCU1fjej4MJM43wtAOh 5MFaYxBXpPYSKCZU99W6AlnjeKp/vkfT+nfJQrxhDxZlW13j0jNVSIm7LWwug+JgJiXg vjDPHcupXhECoJ+SrbJqP0CKSfw7kviYTmkV7F7C8r2Q+OzNbZ9ydgVl7CbuOZPXDj1o 3muB82iQxhLCt1p/VHfSViPA4NZyvixzBFdVN5t/WSC3TgEnPOkx1Y+rzUVQdmhCdFWU ZVAjZneJdUncH30h5/ec9K8WH2yUSBbmBpHDjibEqtMbjmgIXLEbOAnolnwgCyN4des0 E7bQ== 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=TIu5Z/j5EQj7CZAwlLgoDLfGHwCPyPqr2OPtaYu606o=; b=NR8UL25EWB8qCOkWS3NTT+64doFfbpkTbRmXG0DRWyIE7JAgY6zfJewCxY4V5FK2KM NVzdlWy1lx70VhVSBEUza1BmB8lothU/JLu2+GELYc61R3qkgm21tExqllCzV9TUtDsw xQB1NrOoZyx+x/+fB5VL2i8aqeXzQjtiJRcT07P7riECjSUCnqo0c3MJ8A2A5HArxRXX RAkX7xpMfjat/oPnuODFvNPF3FLJac/sjwYF5U+BskREyDD0xofFHlPL5HLI4YxGgfGu szG/LQBfOj+Ue6Us5eGih4diB4dtEeh680p3qgbGmXILeh0VH53Yo+IEt5F8b7gGIoRX QN8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b="x/94/knX"; 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 f17-20020a50ee91000000b0041d94730110si675173edr.278.2022.04.12.01.17.02; Tue, 12 Apr 2022 01:17:03 -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="x/94/knX"; 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 51C4168B3B8; Tue, 12 Apr 2022 11:15:58 +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 449B368B393 for ; Tue, 12 Apr 2022 11:15:48 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751344; bh=zZKLgsJCBqD+N7dXZcBOAbDy5lc00IQKpuBg2z0pJAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=x/94/knXbilLjZlvrMmgiz4VSkvijCa+gebG983YdJ+8RSu73RsInKgDYjM41075E 7o1nbmjQ2iDzl/FrmRi0jBfM6wUokrghMiXlOsD0Cgmscp22wKvsNk1l327aJTEd16 FpqZKjMwICYKdJef8H3xxDrTX/syzh1umPZIob3w= 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: xmsmtpt1649751343tvk3ve4yo Message-ID: X-QQ-XMAILINFO: NC/J3CrDtaBbMRlk7BldDasSotUm60XrPQo/b9BtY3a6nhYlRBJMld3ksnHHV4 SloKBEAjKkc9AXo70kdDoUMhF397qlT2PRVdrxgtnwG6XoWPPwf+Cl2GtYlkzqc/sH5bc5kWTUs6 qFVXIJAfeGko9jCZoVjEnJPNJyrRAyXfNpmAChVSFA3zQGNxJEg99svqTc/lwkltoVseex06j9JB XZNHhdb+OJKj2SQtyhgogpITCF4oo43UNO/pVhZCgYqwlWR4VMh3fxud52M0PaeX5jBqboJxCPyN 9vEhx/dIqlV7BtTLbaUfqYE3FKEpkys4vx4+ekcVZioEPpK+l+gxFXmBUppUc0pB92+oeYr8pJf9 NrlxjwxLJUox4GoeGbsOT/O1yHYFsmVqK5Nesmz06eYGjgM0oNrtbeeTugrI0qzxgMP2tI/i1p6B qpjn4Xhu/AHLMA8L0NGXV7bLMK3JSrPpDnKnRn/W21cOd9NakXh+l1xMRkjHH3DKKnzL+vCYcmsy rv6GRuZkpdGCkwBqphLF5Myd8EMy5gd3Ex0YesKqzNRGzd1A9g/D31UlQGouOPSN616yUsMfS2bZ 2CdtPGwbDeFgT/ONID9snckWFp2ZFOQvMvFNQ3SPo90bxCHEc6fUH6hJvm5vCorPhA9WjFVxoNYE DfyR+gvGS6MCiqX08n2yB27KfrLcYsE/MKLvtKbB0E3+vwI9gG47xNh/mxrqjD9ZEO4Z7rixuL+L mhuM81tgS4eNs/i2tupAsrgIw17uVzDIK0ls5HvXSo4pRPg8w8Tjtg71EOrRnIFPMI9azYzoJTTq 5smOGVOxvY3yFYdq2OoTzES8ESYxd/jT+T139AOChrlMl56Zg63IcRvhR18hS6KIOtfRt3AvoedR 3d0RkI3g6S9TFwfu/S7F0KsHOsOgijcZBFPTeWCTmxGnJ3KRNYwnmiMepMUWFZAQ== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:19 +0800 X-OQ-MSGID: <20220412081522.43246-7-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 07/10] avformat/hls: extract free_segment method 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: lbWfmdlgytQx --- libavformat/hls.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3ed6007d0d..65937120d5 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -225,13 +225,18 @@ typedef struct HLSContext { HLSCryptoContext crypto_ctx; } HLSContext; +static void free_segment(struct segment *segment) { + av_free(segment->key); + av_free(segment->url); + av_free(segment); +} + static void free_segment_dynarray(struct segment **segments, int n_segments) { int i; for (i = 0; i < n_segments; i++) { - av_freep(&segments[i]->key); - av_freep(&segments[i]->url); - av_freep(&segments[i]); + free_segment(segments[i]); + segments[i] = NULL; } } From patchwork Tue Apr 12 08:15:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35285 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454630pzh; Tue, 12 Apr 2022 01:17:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXTYpdrSqfLwGc1sm3pPy8p9lxX+j20hh2lxIlGrpL2roUVd3dI0K55dRdNmCmppwC05xs X-Received: by 2002:a17:907:7f94:b0:6da:64ec:fabc with SMTP id qk20-20020a1709077f9400b006da64ecfabcmr33880150ejc.717.1649751432711; Tue, 12 Apr 2022 01:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751432; cv=none; d=google.com; s=arc-20160816; b=fTXx57RdwEzC3DC94GkBCiOjl6xkogL8gX1m9cIZAQtpPry03NeQqkTExKaxGiIMo7 gatFXucqunaQw4mfnPiCmnyNPMzLRoYxZpweo/00R/GRrfqFwaoNr3+a1VmBiajQ9jpP 90mF2CPcQqG7hbLKFx1Jym33etm1gFKD72yHsRLuoSH4+Gi+h8D5O17A4tlK3LeXva/M +B3dDSsBZ/DuCCgxe5OHd4Yg1Z9irp4XKzP03HSm3xGACgonjrsnxPC06+JwDVb0uB6e QQlJ4v3IvzfMPfXAaYZIRp/NG25OpmeUeiVtxU9xUG/l2ap98vAH7JIhZw32TiKs/WUo XlyA== 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=3KtvuL1cjQ3YQGz1JYmplbKR+MGBgpKEC4nVwOUOEt8=; b=rEfogkPfLB5LyIp7FUWQPmVMTtSqSgKv3Mt0vKlD6KFyDl+EcelfkKSKo7h8mLf1CL XW+owrgYrZI5ZAGB94Hw6rG71zrrEvxpwlw4mkFZcbToX13FVD9KBCkh1iRW22iP5WQO dGIQXd/6TMDdpHa0uAjE8LfYr1Bpc3c+Yk851ZllMrQ5gIpuZ7JOZ1vi83s6cXR2tyNH wgLe19ehYlJXeCsvMn8FBi30KxB9L+cST/orG5Y4J9H7pxpRzMRx+9QGpFp3rIuUnES9 aWG/4M20zS3sEF5NRjAjvU5hHsylkvGRH/bQah69BFdHNABzzCOoMrRCi/t9gd0ZZY1a IoSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b="LQaGLUn/"; 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 y6-20020a056402270600b00418c2b5beaasi9786939edd.396.2022.04.12.01.17.12; Tue, 12 Apr 2022 01:17:12 -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="LQaGLUn/"; 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 2A93B68B3BE; Tue, 12 Apr 2022 11:15:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-240.mail.qq.com (out203-205-221-240.mail.qq.com [203.205.221.240]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8605668B2AE for ; Tue, 12 Apr 2022 11:15:48 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751344; bh=4zcEWou2tCvuTarfMJWotf0hEwKFwdcQ+OHcPjY6EX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LQaGLUn/P+7vbiBpSTxICN0DprnqzLyxadi4Cry3HclrrQDIlSJtPOb+FaRbBreVR 7qWjn1wW97RMxlBosNJN1qReZ78XtxzN0NAZ9wuYbOzFUbWj5OeLMzBBLC/55H3c8A 03PxOtAcQ2SA5TAAgw3+tsbDiuG7p2hhMnBslSoc= 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: xmsmtpt1649751344tfg5omam4 Message-ID: X-QQ-XMAILINFO: NC/J3CrDtaBbMRlk7BldDasSotUm60XrPTb3RsXhEFg7/elRRkIx8fs/aUwqCb MR+w3XAK3Gx0p5jC5UOWqvQUfp7kP9qgb5IICsjeU/xbIXDulQzxHusXWWfZCrvjWTQQQ6JBxwxo 3mE+pRwz4LOWBAXPXW+Vu4mBDcDkNu0j0yRbvLHQAvnK6MwBdNU1/4ZCbHgeE/wzWoIxuQflI2N8 yJXi4B5MeEUhGyN/BnxAaowx/QGFOGd8L5w3/qTryUzCIZVnrYA/XZnW18UifA570gQ/n9nqAN5X T2jFf2Ui9qkLT7OhbHl0h1c+CNjfA3shpp/dnycSNaI3P+KF/IT9cJhCR2ziSEXLVwnePkMEIQ6w tv/56dFeWt9+Tee2ALyk4ZiqzsDfhbSYy1FMmXB/dUJtTIjfF/s8BC/W43GPTloqmhlq1CW/YFZo agZBoQrkghLSkoG8MHoSQqCMQIscg6ZPxZZeT3P5BCV4iT7LlgcL7HgAyvjUpGJDuKgtnw1ip2hR Jl6tkjmX8h6vSCAW4oUT7tQ3PhCUCQ4BD7Rvx2BbOpuXbKcKSAqtPdkHMkfgDcS34Ktsw2SqLQoX oBYPBVqiUs8u6/eAWd4Ii7iQqQ2DK9SykgyiK2z/0/ehrZDVEMYGcJg7phqE6Be3sRkiKLPSGGe8 dvmhOWlZSQIK7rlku4DUmaysg8n3TcZ2h/FQEPzq1/8ep06CXVDa3qBuzw8+Ppph1+e5NGnIUpKh sUWBkL7JPRRvT8M/zSkXo6ENfA1yOoaR+fGZ0tZWu4M35GrxB3UrxsOqGJSyG4dx/BG+ZYob2Yvj /I+gbIRiO0GHYr6X3+TW/WXX1HDG8DFJQ8ugpBSAU+IyOYtgmlSyjnZmQBtLgEQayoA5CLqnXIlr jlC42vBW1h8vP1Wg3EZsqYUt0uWvw0wOXFgenp323J8n4wavTMyWL31ECau2jediDA/IQ5RL3HqS Vsz/nObeJ9DW91voc/6g== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:20 +0800 X-OQ-MSGID: <20220412081522.43246-8-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 08/10] avformat/hls: fix leak of segments 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: uWvePMvEd2zX --- libavformat/hls.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 65937120d5..b9e2e8a04d 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1024,7 +1024,12 @@ static int parse_playlist(HLSContext *c, const char *url, } seg->duration = duration; seg->key_type = key_type; - dynarray_add(&pls->segments, &pls->n_segments, seg); + if (av_dynarray_add_nofree(&pls->segments, &pls->n_segments, + seg) < 0) { + free_segment(seg); + ret = AVERROR(ENOMEM); + goto fail; + } is_segment = 0; seg->size = seg_size; From patchwork Tue Apr 12 08:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35286 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454673pzh; Tue, 12 Apr 2022 01:17:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoCc+FXe2LaX4T0H5yFKnkVKl4YfIFCbBVyerfrKBrfFcVRJ5Y7j7oFqO2M3tm4raln5nY X-Received: by 2002:a17:907:6e07:b0:6e8:b7d4:2c90 with SMTP id sd7-20020a1709076e0700b006e8b7d42c90mr960136ejc.709.1649751442982; Tue, 12 Apr 2022 01:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751442; cv=none; d=google.com; s=arc-20160816; b=azUMA437tcB1uT1ZhCdHnJoDu7AuhCUd1s/LRypvwDTuuSnzRNVOyFd2pLN2HwfFgR Lz3c3vkoZNdFsM0LApxF3a+rhjX1rUgnSlHv9tma8KZMdqj5zPjCEWPhaucINeyCH3B1 lNzQWhV8KJlwTMUkD22xeNyVQpOVO2Cb+umUSLkNQCzB9NETwGKJ8U40vIp1wuRekK0z OQjJTdal9mDI0pqxjW8kNat+BNKh6ryWAQE89/xVUYwiqqPyWJBwhxlB41XvHgHqS0+9 gcTUxwgE/d1DbtmEeuFSWmalq867P0WC6QA4DfHHUJ3L0m7OomfMi1cuNBY3TRABWZY/ I0pQ== 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=f43uDRHW6VrgPzKkmhFB7+J0cVtpktqB2o2bEMZwefs=; b=sg6DFv5XsLbZBT5vGAojYs6LkssiDCzP8xZJdldaPaAU3acqPhiym7cSFOGKX/J3is 805lee8XdiCaRzjrVv5xGqDgiWCB0gEelwJ03ge4SAL9PqoGJ8kuon4jhrRT4u+y+CpP yDu4DTnFnvebJzakYPH8DSFGEz7Ax2BOn8LOym31ulyHmAb2IGv0sgEN/EAQKqETU2fR 5qLRwn3xW3NWbutEVDq851sg+uBgBkFBkme7tduPkfQOZcxquI7MDcQynA3xGFFgTHf2 eBBz8bSADo9m9fnmor8QSZmImj7DYu3XhEVx/7Xt07UpO621toMrzTqGZz/4Ks0hLj/8 fywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b="EwUX/lct"; 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 dt5-20020a170906b78500b006e78f6856c7si8363262ejb.613.2022.04.12.01.17.22; Tue, 12 Apr 2022 01:17:22 -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="EwUX/lct"; 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 36D1D68B3C6; Tue, 12 Apr 2022 11:16:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-149.mail.qq.com (out203-205-221-149.mail.qq.com [203.205.221.149]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2023868B39E for ; Tue, 12 Apr 2022 11:15:48 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751345; bh=mifUvhe+hXUz2FvvQBlp9NdKHoT6tvKLJ4Rsy5deXSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EwUX/lct8p7htW20PbrYQyOS6+GLDRVra7sCPKu9TcEfm5gkQqqAiX86Bu6+Wauca A3aLgCri8ZSIlWEQDo4xJB3AiowdeoI6M9EGYAD7o20l0CfNQarYlC/xddiIJkIP5v u1n7sCAi0KlQFfuq9KZeEjvKrz1bCEUg7ObSrUgg= 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: xmsmtpt1649751344tr50rbh93 Message-ID: X-QQ-XMAILINFO: NPwOoMPVnumVddBZXXUF5Y3MWYhpSFzGaUlj35o8eQYRdSy092Nkkhicsg3D83 u+Sd0fij5y34dJHT+2fQL3qpCWd/jAQUSftChy1nnXXuE+3lW/Ev8JG82wXNYCflB/dhlvbOIYTy p3nnqYQ/v+TlH7xppB71mgCtrhNAZvYnpeSv1HNS19leYwg+g2E7KRNcKvuCddBb9y9PHfCjeu7V B4MNYx+54pgTBT4Xv6DH9L/b8jHosUd+3s+AnR/hPYn3eXOrl19thYc2I947QpSs8Eakqyi8iOL+ jDg7FqYqwovPzVP+4CcP8y3q/S+q58fAtl0bFzzqW3wU/IsROHnN1xH2VcALR7SA3LhBeANePY+0 VjmljsJiKdoEc5lI51XPC7KYoE7EQn0y5j1oIE4bQFbeBuyLeCG8k4H14vM7OjBo4qNMTQGJRTIu 6lVcUB2Vj/lClH/XXMqtrhPBh9Iz3oXKTAlB7/Ebthugtt+GMlFdgEudBy4eKY4aT6rBpW1HJeRz dNlUkYxyMaR1NcKywfkr/UHlk4g2XemeDLK6sMp/SNlKpN+QRQzV7R1bhAjLRrq4IvoSDkCeUHbq 3G8xEeWPNTRbDPdvgUlUmEFqz60JLEshtREm0KvgRjNKg9GLwhQSACgiGgzy7w5lXHp7cTymBJBE bPMidn+O4Cci+82OhKhoIeItcAxieIfqaJLOpRtjbjN1doRgrPVi4Xv71ROks2fpJ83y3pXatvPb APrU/d1O9Duu6L30vAYvUMxsYatQ8uQvlq36NwmfhJBLNUudKXOroFXi0BtUA/IR3Ge0J+ZYh3EU IA4ty8cUQ6qes2r2nHq0T8+621kZxfs2rxrl1ERv+TBILkG6KH7e9LeG4SrreReh3EwLHGoFyeVt dksiTIL1Vs+MtCMIWekC/2AMWrp0v8F7SLuXvtw+WS3JAxmYEzT3uMWa/0OGEyu4NOfOiTwzhSc+ 8Atk0SDYbD0Ni1KNI9Mw== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:21 +0800 X-OQ-MSGID: <20220412081522.43246-9-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 09/10] avformat/hls: do error check in add_renditions_to_variant 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: srX7uxwreNx0 --- libavformat/hls.c | 49 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index b9e2e8a04d..c102e36f52 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1666,9 +1666,10 @@ reload: goto restart; } -static void add_renditions_to_variant(HLSContext *c, struct variant *var, - enum AVMediaType type, const char *group_id) +static int add_renditions_to_variant(HLSContext *c, struct variant *var, + enum AVMediaType type, const char *group_id) { + int ret; int i; for (i = 0; i < c->n_renditions; i++) { @@ -1676,18 +1677,26 @@ static void add_renditions_to_variant(HLSContext *c, struct variant *var, if (rend->type == type && !strcmp(rend->group_id, group_id)) { - if (rend->playlist) + if (rend->playlist) { /* rendition is an external playlist * => add the playlist to the variant */ - dynarray_add(&var->playlists, &var->n_playlists, rend->playlist); - else + ret = av_dynarray_add_nofree(&var->playlists, &var->n_playlists, + rend->playlist); + if (ret < 0) + return ret; + } else { /* rendition is part of the variant main Media Playlist * => add the rendition to the main Media Playlist */ - dynarray_add(&var->playlists[0]->renditions, - &var->playlists[0]->n_renditions, - rend); + ret = av_dynarray_add_nofree(&var->playlists[0]->renditions, + &var->playlists[0]->n_renditions, + rend); + if (ret < 0) + return ret; + } } } + + return 0; } static void add_metadata_from_renditions(AVFormatContext *s, struct playlist *pls, @@ -1987,12 +1996,24 @@ static int hls_read_header(AVFormatContext *s) for (i = 0; i < c->n_variants; i++) { struct variant *var = c->variants[i]; - if (var->audio_group[0]) - add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, var->audio_group); - if (var->video_group[0]) - add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, var->video_group); - if (var->subtitles_group[0]) - add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, var->subtitles_group); + if (var->audio_group[0]) { + ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, + var->audio_group); + if (ret < 0) + return ret; + } + if (var->video_group[0]) { + ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, + var->video_group); + if (ret < 0) + return ret; + } + if (var->subtitles_group[0]) { + ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, + var->subtitles_group); + if (ret < 0) + return ret; + } } /* Create a program for each variant */ From patchwork Tue Apr 12 08:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 35287 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1454721pzh; Tue, 12 Apr 2022 01:17:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+eO2fTitmTNRzTvZtrbqjs/bBj5mUfDDBoU8rGqrIR1U/pXyiElRvzm7o5Fw+Qpl1LFU6 X-Received: by 2002:a17:907:6e04:b0:6e0:95c0:47b8 with SMTP id sd4-20020a1709076e0400b006e095c047b8mr33710244ejc.483.1649751452355; Tue, 12 Apr 2022 01:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649751452; cv=none; d=google.com; s=arc-20160816; b=r5RAx8Ts6h+nzZxboBPQAUyETRJC134BqUuhY78R9LIba2Abiy3jh2xH6qXFEzYPXh F/if0BehOuN7620A6yMpMDFSS75fyGTLfUSZqAGL7eCBzofzbGLTh5ClVcRM95yR4G+i A8y9FbJ1rXRBLNG4dfYKNJjd1XsRvcN7QlBFHhw5EH/0WLf5bxnuOUNW9hdGRFP5+RYl I1jBgRRnn513fhGZeE/HJKY2A3SkjaCusdF9F+krEixhrVAWdW8NuPMLmvQOPbz6+fIO tn40ZD5Ub1EWWxiZyHAiI8cS/Apqq4+fBvrBcxWleCkOYMnVzINayU9bkC/GORzY56oB lnbw== 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=Ln5fgukDdA6XIGwkYOuLgB8QPbgj6cQIqF/yB7XddLU=; b=J58P67pHqvTET88N2tO75tWAuE2vOPT7FBmXMZwQsceDiH5zaaZXN+Hetfy9NUztYN bzmF18ICbzJ4qF/U+SnS01NeAXegCtQCZEOTYeKaLSkQ19powNnjqKIxCm7rcSOGiaxQ 5iigLecWNmJcLbeBv6YuDXTCc42Hpk6u90zlRg+qrlPAGKbqrjf5Fsj83TGc8VRtrneI BJUcxhGyieYsyLh1y+jGn2T2DawMj65xxKKOem4B2oTZE7OITKLHnRzo21zNyUDuICSr vLlqT7vojKBHDkIm3pG1D1y3WAlwp7Mjkgq9igiHkte0wulHuagWz37XL+R9aVTWW42p 0HMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=k+lqutcD; 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 go15-20020a1709070d8f00b006e7fe2ddfcdsi9217963ejc.428.2022.04.12.01.17.31; Tue, 12 Apr 2022 01:17:32 -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=k+lqutcD; 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 35D5D68B3CE; Tue, 12 Apr 2022 11:16:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-245.mail.qq.com (out203-205-221-245.mail.qq.com [203.205.221.245]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73A0968B39B for ; Tue, 12 Apr 2022 11:15:49 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649751346; bh=HP7GmNQviZRCgVDjFqLg87r73xqYgJLzQdjZf5AtgqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k+lqutcDa0aCJz4d6Gx5vlSd36oXPwKB8LxusgnYdLzxyKRGx8JZKwze/9cxiOdYv GKR9qayHwBOcQPhJPIZeJkez+2vZedn8ASqeJ6hBA645qcb9NLKKTcMYnhUmtiUbF5 y1Oqdmf2AVPohE6TTvGe3Sr5UjCelR+KOIx342yA= 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: xmsmtpt1649751345t4kiieele Message-ID: X-QQ-XMAILINFO: OBfNkvzAyASsgGf+3tIOEI7e3njBoEx57eQeeNwTuf+gOSXoaMP7oSvax5uIev GdgKeNDjbyve1qiy8RXSZiyHdBpeN3n+MSGs9wlpMtC3eYx6ymUPGNPpdol9JYGF2kQDEMKJpAzZ Ed92NIs8m/4RgNvO4dRWOzECJLY8m/KwO4W9A8OTVyTiMbT5D+sCn1gV5AZQyUqWEllnocHVoWic ExWKN0gqbELbVj79mskCT6x9zu6ZgS8z5LY5PfjGx30QUYiicTG+HEDxdu3XDeyAsKZMjM6BhTyN aPSEaeTRZv0kTF8JLRh9RzYiyAri2aQ7FcPhn2kKBd97nr3z3RXKP7ExJWqEGfJ7l1nZ5wP2OkV7 7w59JXjOXtHBH9pVrCB+0cFooWX5QOXizphqBlNLnYMvDc26HS24kgA0oH040iDRUbSXm+Vy5Ii/ yZ8CCRdjO1HharDx3+VzXF7eTou4rvnm9Ps1AXcNv/W0xHb8ieM94nPoZSJqScevMTE87gK5+KYt LnpCsGMtcIKwhlK18M1f7wKYhG2o95BbY8TT2FsC/3Q3R9Mb3BkKvBf7VmnACdI+7XloGJoNW5cf unp/3mgahP78DR6jhtmuVmdQApOZCXZSMdyDJcSZEqqlgxeDtzHGvgzLU2gCgsHdj9AJ/i98G8zC xwEJFB2He/QOswqgMsDFbVzizoy1Y7xnJnbw5i4zK6zIs5L8UhJbnxtjMizV93Sjsgdpd7eEyaaU QSd0d7Ky71/3Uwb+QM76z4oRWFtlBdjaCTCtV+geRRrQXWQFcI9GFWrk7WGX6RzojhphX1uvO+27 eAqT0LXi/OCtuxQ0ymqpJ8vpqSOwYpkB3Pq6xDj9QD1j0kG+M74xGsgTzzs44naMzXO2Roh38zYx rhsR8FWgiGyvqIeqnmt5sLa8PohKlOzVVwlU03HAlMRAPLe95nj2QRVvggLy4n7wRm/OetlzGn From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 16:15:22 +0800 X-OQ-MSGID: <20220412081522.43246-10-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 10/10] avformat/hls: check dynarray_add error when add stream 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: vgeNgp91rvC9 --- libavformat/hls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index c102e36f52..4ab565f8e0 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1882,7 +1882,10 @@ static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *p return AVERROR(ENOMEM); st->id = pls->index; - dynarray_add(&pls->main_streams, &pls->n_main_streams, st); + err = av_dynarray_add_nofree(&pls->main_streams, &pls->n_main_streams, + st); + if (err < 0) + return err; add_stream_to_programs(s, pls, st);