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 */