From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E1BE942A54 for ; Tue, 12 Apr 2022 08:16:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2406568B39E; Tue, 12 Apr 2022 11:15:56 +0300 (EEST) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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]) { -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".