From patchwork Tue Jan 4 06:10:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 33046 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp16715806iog; Mon, 3 Jan 2022 22:11:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwm5AzRhBnZH8QSQpBtmoCSBtqxVgEi+DZ8QdYeQz+aQZphZutWtDxuoz1/X1IGjzqeBwAL X-Received: by 2002:a17:906:c109:: with SMTP id do9mr38011992ejc.111.1641276673865; Mon, 03 Jan 2022 22:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641276673; cv=none; d=google.com; s=arc-20160816; b=wnwIzuXMXwoxsBdDTVp8tGuzb4GnskignT/mTgjfReCt4N4UORPlAtksTEwuxLd6We H45OWHygQakpy3gK8xZHyZ/WTpbuIi0YFvSBl0fTGJdV/klSq/Vf2toL1izwARvPc0KK 5fYAp4pJy99i79MnYfb04duIXXF2/lxUYjAezW9r3daaFVs5OyHnE+iuIV2qSH/VhsFD E+DGK53SYywKcli7cFx6HQ65qq6YSPPUN8g/J3+QdRgaLzL/gPIg+NqghbfKI+K95FIH 7foPupJo9ib8mBzvg8GbLHFKY5mYbZYsgHh0Fkfhs1AFmKA3yQpyQqisriLFgML2rP+W fs0A== 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:message-id:date:to:from :delivered-to; bh=CQnNBgVxWrCXd4JtxGte9B6QHB07peVsdO3sD4ojJzs=; b=kANwrGRBtdu+xqIHyGlOzT9MykehORQnOP18ifZaN2qJwu4DO4a2COHXoR8QtTE0Yi fI3g1Klwg1U7wddKR66F9XF5eKqX8Bu/wno/htfd3dEbiF1b0Tp/0aYlDTukZxw3NRbL VoBreB7JHndAlK6Mgg9oiVY6uEq4ZjY7bjj56Xw6B1MTzpAQXgDAohEharhvXXl/6F2H z7iiAMouAoZlIttQAOVJVj0UhpIDnGmqyzh8fgS2X27H8XrUPvUTxaUqDk2ho25Fd4N2 nBTPkrVxZlCSIr9DeBMndAEwaRFxWHIocsfmIxXqk/JGdsYv72/j8gHcTcFLXSU6RS9v MYQA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hr41si18976197ejc.184.2022.01.03.22.11.13; Mon, 03 Jan 2022 22:11:13 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 427E768B156; Tue, 4 Jan 2022 08:11:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE1B168B036 for ; Tue, 4 Jan 2022 08:11:02 +0200 (EET) Received: by mail-pj1-f42.google.com with SMTP id iy13so30510793pjb.5 for ; Mon, 03 Jan 2022 22:11:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KxF92+NxF9NNDjHh7mflbQa8br4ingXYPNwOfQoPVeQ=; b=Tv1zJxf2mPN8CUhDo3KcLivQBpBMAvy3b3iz/VlEFrjZ2tksSeDNMVjMyE3dO8l9RH XrI4VcUOVgwVxgJ81IaBB9Qls04rn+S7dPP47wuCn8ToADH0oRQpY1v2JjBe/ADvEsz4 /XEIhk36bEfyOiz/brHJmP7ZOshSsjPrZP3FCwPu7YMFSqw6JmiEQ7oUDiwA6ZfYNgLC bH9tMBEdQqVkX3p9l/MzLavdOMEKBvbVOGMCXkpUXZBZltHh/JyPl2UYmIVHP6N7EuAF 5RzHu89REnLgWroZIYIFU9St1SOXkz3RNa7Bw0DLO+jSH2vbtWX0+49wA57dWwBsiUVP MQFQ== X-Gm-Message-State: AOAM532Nb1AmTHg8H9857UkXTHihxdaWCh1dCRaPeK70gn0TjHuZ9tbF 67EhJHZvZfk7h6iOgi2StieA/MhHp/E= X-Received: by 2002:a17:90b:234c:: with SMTP id ms12mr59288017pjb.36.1641276660883; Mon, 03 Jan 2022 22:11:00 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id rm6sm9873411pjb.35.2022.01.03.22.10.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jan 2022 22:11:00 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Mon, 03 Jan 2022 22:10:57 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Jan 2022 22:10:56 -0800 Message-Id: <20220104061056.32737-1-pal@sandflow.com> X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1] avformat/imf: fix CPL parsing error handling 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: a2nmmwR5VWQ6 From: Pierre-Anthony Lemieux Signed-off-by: Pierre-Anthony Lemieux --- libavformat/imf_cpl.c | 51 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 167244a5a2..72fc7ffec8 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -807,34 +807,37 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) av_log(NULL, AV_LOG_ERROR, "Cannot read IMF CPL\n"); if (ret == 0) ret = AVERROR_INVALIDDATA; - } else { - LIBXML_TEST_VERSION - - filesize = buf.len; - doc = xmlReadMemory(buf.str, filesize, NULL, NULL, 0); - if (!doc) { - av_log(NULL, - AV_LOG_ERROR, - "XML parsing failed when reading the IMF CPL\n"); - ret = AVERROR_INVALIDDATA; - } + goto clean_up; + } - if ((ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl))) { - av_log(NULL, AV_LOG_ERROR, "Cannot parse IMF CPL\n"); - } else { - av_log(NULL, - AV_LOG_INFO, - "IMF CPL ContentTitle: %s\n", - (*cpl)->content_title_utf8); - av_log(NULL, - AV_LOG_INFO, - "IMF CPL Id: " FF_IMF_UUID_FORMAT "\n", - UID_ARG((*cpl)->id_uuid)); - } + LIBXML_TEST_VERSION - xmlFreeDoc(doc); + filesize = buf.len; + doc = xmlReadMemory(buf.str, filesize, NULL, NULL, 0); + if (!doc) { + av_log(NULL, + AV_LOG_ERROR, + "XML parsing failed when reading the IMF CPL\n"); + ret = AVERROR_INVALIDDATA; + goto clean_up; } + if ((ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl))) { + av_log(NULL, AV_LOG_ERROR, "Cannot parse IMF CPL\n"); + } else { + av_log(NULL, + AV_LOG_INFO, + "IMF CPL ContentTitle: %s\n", + (*cpl)->content_title_utf8); + av_log(NULL, + AV_LOG_INFO, + "IMF CPL Id: " FF_IMF_UUID_FORMAT "\n", + UID_ARG((*cpl)->id_uuid)); + } + + xmlFreeDoc(doc); + +clean_up: av_bprint_finalize(&buf, NULL); return ret;