From patchwork Fri Dec 7 04:49:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 11323 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 669ED44D3FB for ; Fri, 7 Dec 2018 06:49:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9EAE968A85B; Fri, 7 Dec 2018 06:49:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i252.smtp2go.com (a2i252.smtp2go.com [103.47.204.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F2DA868A2FA for ; Fri, 7 Dec 2018 06:49:33 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1544159088; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=x5Z7Mxue65K5npTgjzrpshPYwZZTOoB//IdiNuaIDkQ=; b=IkAVFDVk hr6dWXkM9ta4Q9+VI8e1x9fbb/C7TtY9jzH08VkSDXBZtMRT9DeBvJyKn9nOucoPd/W7p1hMzr5Zr LhTPTvNWs3WDZxr2B8aLTxal1miXGD19gIBATWlCNtrfkhIa26ld1HGvwRb4/i0lDDLeGRj92Dcda 0EOt6tA+MLsy3es1soss35uckzZCQZdG9VUNi/eLGacEdzCU7O6pdBWW0z4uVNnSfKEHetVT2dkvC vVrqCYTqQBDMbXNE+F7GgKJmd+NXRv10mU21+HipiqkaizCHcjYnLIXDKgOSsqaJnfTBprmDfDEyK AE8LJmFEdBiiTrZQi4eeJaY87g==; Received: from [10.45.79.71] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gV856-095CG1-C1; Fri, 07 Dec 2018 04:49:40 +0000 Received: from [10.63.208.195] (helo=blr-mp4tf.bangalore.corp.akamai.com) by smtpcorp.com with esmtpa (Exim 4.91) (envelope-from ) id 1gV855-Duuh6G-0t; Fri, 07 Dec 2018 04:49:39 +0000 From: Karthick J To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Dec 2018 10:19:29 +0530 Message-Id: <20181207044930.65216-1-kjeyapal@akamai.com> X-Mailer: git-send-email 2.17.1 (Apple Git-112) X-Smtpcorp-Track: 1gV855DIIh6G0t.CPvizyWlA Feedback-ID: 337386m:337386asVRLGB:337386sfSI_lSoVN X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: Handled error from ff_http_do_new_request() function 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: Karthick J MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This patch fixes the segmentation fault issues due to unhandled errors from ff_http_do_new_request function. --- libavformat/hlsenc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 31ef0237ae..42adcfbab1 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -241,6 +241,9 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, URLContext *http_url_context = ffio_geturlcontext(*pb); av_assert0(http_url_context); err = ff_http_do_new_request(http_url_context, filename); + if (err < 0) + ff_format_io_close(s, pb); + #endif } return err; @@ -249,6 +252,8 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) { HLSContext *hls = s->priv_data; int http_base_proto = filename ? ff_is_http_proto(filename) : 0; + if (!*pb) + return; if (!http_base_proto || !hls->http_persistent || hls->key_info_file || hls->encrypt) { ff_format_io_close(s, pb); #if CONFIG_HTTP_PROTOCOL @@ -2329,7 +2334,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) } vs->packets_written++; - ret = ff_write_chained(oc, stream_index, pkt, s, 0); + if (oc->pb) + ret = ff_write_chained(oc, stream_index, pkt, s, 0); return ret; }