From e02f74a492032662f663f094f923678b43142a46 Mon Sep 17 00:00:00 2001 From: Timothy Drews Date: Thu, 20 Aug 2015 18:13:53 -0700 Subject: [PATCH] Add destruction check in Stream.switch(). This check is necessary since Stream does not own its StreamInfo, so the async part of switch() may complete even if Stream.destroy() is called Change-Id: I5185c0df3184924d0f34d39e235b1155f01dd273 --- lib/media/stream.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/media/stream.js b/lib/media/stream.js index 42ad8e346d..dba5856ca2 100644 --- a/lib/media/stream.js +++ b/lib/media/stream.js @@ -264,6 +264,11 @@ shaka.media.Stream.prototype.switch = function( Promise.all(async).then(shaka.util.TypedBind(this, /** @param {!Array} results */ function(results) { + if (!this.video_) { + // We got destroyed. + return; + } + var previousStreamInfo = this.streamInfo_; this.streamInfo_ = streamInfo;