From f9908362f82049431d26ddc2e96a917f76ddcad4 Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Mon, 8 Mar 2021 00:01:08 +0100 Subject: [PATCH] Prevent seg fault if webm fragment is not initialized or last frame is EOS Fixes #900 --- packager/media/formats/webm/segmenter.cc | 2 +- packager/media/formats/webm/webm_muxer.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index b3ffdcfb18..52e4338124 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -150,7 +150,7 @@ Status Segmenter::Initialize(const StreamInfo& info, } Status Segmenter::Finalize() { - if (prev_sample_) { + if (prev_sample_ && !prev_sample_->end_of_stream()) { uint64_t duration = prev_sample_->pts() - first_timestamp_ + prev_sample_->duration(); segment_info_.set_duration(FromBmffTimestamp(duration)); diff --git a/packager/media/formats/webm/webm_muxer.cc b/packager/media/formats/webm/webm_muxer.cc index 5f1d516577..18e8a51dd0 100644 --- a/packager/media/formats/webm/webm_muxer.cc +++ b/packager/media/formats/webm/webm_muxer.cc @@ -47,7 +47,8 @@ Status WebMMuxer::InitializeMuxer() { } Status WebMMuxer::Finalize() { - DCHECK(segmenter_); + if (!segmenter_) + return Status::OK; Status segmenter_finalized = segmenter_->Finalize(); if (!segmenter_finalized.ok())