From patchwork Sat Jan 20 00:59:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan McGrath X-Patchwork-Id: 7352 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp165369jak; Fri, 19 Jan 2018 16:59:50 -0800 (PST) X-Google-Smtp-Source: AH8x224QxFPJjR6ednvoFKZMlqZ5CNFzYs4XpypAFkbRQBU2+9KuH/7ULL0sXTU9gFkZBwe3pEkf X-Received: by 10.28.231.8 with SMTP id e8mr24863wmh.148.1516409990497; Fri, 19 Jan 2018 16:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516409990; cv=none; d=google.com; s=arc-20160816; b=njHMqM/kN2BumvM4DzIzF+W+NvajhWkLKZ53C/+2FJhaXzV4Zbq/oGUQBi5kxAus45 QvmCH/3QKXZgtYMOA5XF73KLOd4V5gOGV2y9G0brdaAGVI2ktb1e0bOp6riSTjPxFWuw 9zheucs2q3FkX3lbW9Y33DMTzL7xZQ7f51IhBEmHjuX0z41OYPybQVMFPYUa50TZu6VS R0T7wv0mD0cjPoNj7H0QJq+KX0Ne3vrGqmsOV+uKBJlgEXyUgihtu4PrSiz5SHHUmHef fTVRwgBFfZyqKvczAQMd0YR7mG/NwDCJ2KX38jjcYt03Kw1g9D8cMHV0FRtKdxti1khr TiVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=WPu1dBl6/pAmaMItxgIGw9qQWuZ1vBoBuWpA3fN6mmc=; b=sJt1TIrGU3XA2nidOQJ3yF/MLEkSLODXGpIZhHigs/9xwSFS6wJ/JJK4ev0PyMsZ7R T0wxieXFvDjNgosh09RU7Q4jomEyi+cTxUIwn7l0T+riDUhrhueNKsumHeC0WtyzJ2on IwlQOd00G75lRO+hk7PRPz3APCHOiprzKbL0Oghz6PQfQqn0Xx0lCb2yBCrvmijy6ZDw jeENwimVQ5aspv+TBYswfwbO+Y6mgx5c4i690SWol5oQdzx0qXWL0r1QtC0PU9B3MhfJ RXQpKinAm2SjGu1RtCBN3ZqJ8V9wdKvB13JsWQk0wsC2bqpBUdFDtEcZUBiTeYmslx+o E+4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@hermana.com.au header.s=2016 header.b=LsgcVUXj; 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 o135si1606346wmd.101.2018.01.19.16.59.49; Fri, 19 Jan 2018 16:59:50 -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; dkim=neutral (body hash did not verify) header.i=@hermana.com.au header.s=2016 header.b=LsgcVUXj; 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 4C77A68831F; Sat, 20 Jan 2018 02:59:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.hermana.com.au (ec2-13-54-119-68.ap-southeast-2.compute.amazonaws.com [13.54.119.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1F4068831F for ; Sat, 20 Jan 2018 02:59:41 +0200 (EET) Received: from brendan-desktop.localdomain (2001-44b8-412c-1c00-3def-8e15-6d55-724d.static.ipv6.internode.on.net [IPv6:2001:44b8:412c:1c00:3def:8e15:6d55:724d]) by mail.hermana.com.au (Postfix) with ESMTPSA id E498345; Sat, 20 Jan 2018 00:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hermana.com.au; s=2016; t=1516409979; bh=aUcrOxyM7IhbX+dFG1kp7dHoyGxccywVNvw3oHhIz0o=; h=From:To:Cc:Subject:Date:From; b=LsgcVUXjsbzlbSC852QnsHBCAAmnrGsec01eyGjclOUXKsdbULWB1S4AIB1v1K1GK CKJyP7M6zodVySs1BFGFgRzsPffqUu1QIfVehi/51ciSzUu1XKuYBYk5TeIysh1uzc 0vg2T5RbgUme0j8AcotEKoR/dp9ekgQQ0iBe4b1A= From: Brendan McGrath To: ffmpeg-devel@ffmpeg.org, Steven Liu , Christian Suloway , Karthick Jeyapal Date: Sat, 20 Jan 2018 11:59:30 +1100 Message-Id: <1516409970-16621-1-git-send-email-redmcg@redmandi.dyndns.org> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: Check that data is set 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: Brendan McGrath MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If codecpar->extradata is not set (for example, when the stream goes through the 'tee' muxer), then a segfault occurs. This patch ensures the data variable is not null before attempting to access it Signed-off-by: Brendan McGrath --- Before the var_stream_map option was available - I was using the tee muxer to create each resolution as an individual stream. When running this configuration after the most recent hlsenc change I hit a segfault The most simple command which recreates the segfault is: ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 \ -f tee [select=\'a,v\':f=hls]tv_hls_hd.m3u8 libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 8ad906a..42e437f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) { if (st->codecpar->codec_id == AV_CODEC_ID_H264) { uint8_t *data = st->codecpar->extradata; - if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { + if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { snprintf(attr, sizeof(attr), "avc1.%02x%02x%02x", data[5], data[6], data[7]); } else {