From patchwork Sun Nov 10 04:07:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16195 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7891744AA42 for ; Sun, 10 Nov 2019 06:32:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C83C68ADC1; Sun, 10 Nov 2019 06:32:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0BD668AA51 for ; Sun, 10 Nov 2019 06:32:06 +0200 (EET) Received: by mail-ed1-f66.google.com with SMTP id a21so9324860edj.8 for ; Sat, 09 Nov 2019 20:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DGmTj34tylXPnxHu41JW9t/TDDOdwEox0T1GOeGOccw=; b=r7U70xVJ5zvRjgs0pc6jCmMhElinQK572VY492YVpJ73YXhtpZ82Kt+mC/PMAW7b1n MUdebrKzpofxNkkXEu39RDOn0NuEPuo+TYRHVYNc0Tn8qg5fdexPndzP2uhmMIIqi11R tEcI3pZbC5zHo2QKNcPZBr2kYSo+iEBtPgwV8sQrm4cePYhIiLThX7pjJgzWuZT3+vqy EtM/SEARxaJaBzHvzuddT8Nbd/S98+bqah8l0gQDx2hNDLGanFyK73rGNvnEQhwvcOct 9XtLAYFkP+k2piufYDTip0GuKHmjn7/S3OxarIMFNzA2ezoCCGaed+zRE7kviFb53Xxl zqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DGmTj34tylXPnxHu41JW9t/TDDOdwEox0T1GOeGOccw=; b=sMIbdyiqdpXzpC68dqqQx8n44Vx1RjaOZVV9z77ZdXLoSdP46VmZ8A+JNAl++avZYv R3q55ICAVxzLokBPX4s18GJPAeJNFFqySEezTn7Pa3uNwUOVXDqG5aPClQsVR7EV3EJw Zz2XzzGADgGUD1ZZIhgtsjqWvseYk3xzKDbNk1uQBlNahemRP5WvxeDGAT3lSJCm2VpR ek9Bwsu8cteSTFSAAeENj2HPiYwButn4EOZeSjh/FSVwqiAwx6oRfKLDpLG6xlJdDov/ wd3oPHoDQ2ZJMMCXEZcA6zsFZwYxjuzUF0f6SCexPT4O0Ge/CzXELD6kD0/CS29MebyF KRzA== X-Gm-Message-State: APjAAAX7l4/0R6rrLTPMGQw4sRBNBWc0D1OqFG8RUs0W1jT/lLjGD46/ 5orRE4jy5emJRlERYaclRCH10zjQ X-Google-Smtp-Source: APXvYqz98YkFuBB4mXsPHLdri8OSSlbmuOanx9wNTwsi/DSEvdahLS0oaYontiYGwsCRxJNSng1c1w== X-Received: by 2002:adf:ea88:: with SMTP id s8mr15233929wrm.120.1573358864214; Sat, 09 Nov 2019 20:07:44 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08937.dynamic.kabel-deutschland.de. [188.192.137.55]) by smtp.gmail.com with ESMTPSA id q15sm11381781wrr.82.2019.11.09.20.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2019 20:07:43 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Nov 2019 05:07:29 +0100 Message-Id: <20191110040733.11755-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191110035406.11500-1-andreas.rheinhardt@gmail.com> References: <20191110035406.11500-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] avformat/icecast: Free the right buffer on error X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In case an AVBPrint was not complete, icecast_open() would free some buffers that have not been allocated yet instead of freeing the data of the AVBPrint (if they have been allocated). Because this error does not trigger a jump to the general cleanup section any more, one can moreover remove a (now unnecessary) initialization of a pointer. Furthermore, finalizing an AVBPrint can fail (namely when the string inside the AVBPrint has not been allocated yet) and so this needs to be checked. Signed-off-by: Andreas Rheinhardt --- libavformat/icecast.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/icecast.c b/libavformat/icecast.c index d2198b78ec..052cd37f3e 100644 --- a/libavformat/icecast.c +++ b/libavformat/icecast.c @@ -89,7 +89,7 @@ static int icecast_open(URLContext *h, const char *uri, int flags) // URI part variables char h_url[1024], host[1024], auth[1024], path[1024]; - char *headers = NULL, *user = NULL; + char *headers, *user = NULL; int port, ret; AVBPrint bp; @@ -105,10 +105,11 @@ static int icecast_open(URLContext *h, const char *uri, int flags) cat_header(&bp, "Ice-Genre", s->genre); cat_header(&bp, "Ice-Public", s->public ? "1" : "0"); if (!av_bprint_is_complete(&bp)) { - ret = AVERROR(ENOMEM); - goto cleanup; + av_bprint_finalize(&bp, NULL); + return AVERROR(ENOMEM); } - av_bprint_finalize(&bp, &headers); + if ((ret = av_bprint_finalize(&bp, &headers)) < 0) + return ret; // Set options av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0);