xbmc/xbmc — pull request #1971 by Memphiz (2012-12-21 21:28:53+00:00)
Title: Fix crash when stopping music - FRODO FOOD!

When paplayer gets stopped in the last 5 secs where the next stream is already slaved the stop is blocked until the next track starts (no clue draining the stream i guess). In that case the onplaybackstarted callback for the next track is fired even if we are about to stop. In the message handler the current playlist is fetched and accessed directly with [] operator without checking if the playlist is still valid. This leads to bad access crashing because the playlist is empty already when the started message gets processed. This fix just fetches the playlist and checks the size before accessing the playlist item - fixes #13792

This is for frodo. I'm doing it as a PR because i was unsure if the early return true is right in that case. Talked about it with Montellese already and Martijn verified that this fixes the crash for windows too (and i did tests on osx).

@davilla @jmarshallnz for review