From 84c6e09c423c74c4b5ffe3fcf602bf42149e8461 Mon Sep 17 00:00:00 2001 From: BetterCallMolly Date: Sun, 3 Dec 2023 14:51:59 +0100 Subject: [PATCH] Player: Fix crossfade crash when decoding fails When the decoding of a track fails, `current_item_` is set to an invalid address, if the Crossfade option is enabled, the `Player::TrackAboutToEnd` method does not check whether `current_item_` is a valid pointer or not, causing a segmentation fault. Player: Removed extra space --- src/core/player.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/player.cpp b/src/core/player.cpp index a7ffd7fe..248d5bc0 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -867,6 +867,9 @@ void Player::TrackAboutToEnd() { if (engine_->is_autocrossfade_enabled()) { // Crossfade is on, so just start playing the next track. The current one will fade out, and the new one will fade in + // If the decoding failed, current_item_ will be null + if (!current_item_) return; + // But, if there's no next track, and we don't want to fade out, then do nothing and just let the track finish to completion. if (!engine_->is_fadeout_enabled() && !has_next_row) return;