From 09cdb69e6a383b4152a3ff1ed817c24c12688120 Mon Sep 17 00:00:00 2001 From: nhnielsen Date: Sun, 2 Dec 2007 13:11:07 +0000 Subject: [PATCH] Fix list index out of bounds crash on loading of .pls playlists, thanks to Tim Beaulen ( tbscope@gmail.com ) for this one git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@743966 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/playlist/PlaylistModel.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/playlist/PlaylistModel.cpp b/src/playlist/PlaylistModel.cpp index edd2f23e0..198b599f4 100644 --- a/src/playlist/PlaylistModel.cpp +++ b/src/playlist/PlaylistModel.cpp @@ -497,17 +497,21 @@ Model::insertOptioned( Meta::TrackList list, int options ) Amarok::ContextStatusBar::instance()->shortMessage( i18np("One track was already in the playlist, so it was not added.", "%1 tracks were already in the playlist, so they were not added.", alreadyOnPlaylist ) ); } - int orgCount = rowCount(); //needed because recursion messes up counting - bool playlistAdded = false; - - //HACK! Check if any of the incomming tracks is really a playlist. Warning, this can get highly recursive - for( int i = 0; i < list.size(); ++i ) - { - if ( m_playlistHandler->isPlaylist( list.at( i )->url() ) ) { - playlistAdded = true; - m_playlistHandler->load( list.takeAt( i )->url() ); - } - } + int orgCount = rowCount(); //needed because recursion messes up counting + bool playlistAdded = false; + + //HACK! Check if any of the incomming tracks is really a playlist. Warning, this can get highly recursive + for( int i = 0; i < list.size(); ++i ) + { + if ( m_playlistHandler->isPlaylist( list.at( i )->url() ) ) { + playlistAdded = true; + m_playlistHandler->load( list.takeAt( i )->url() ); + } + } + + //fix crash when list is empty + if ( list.isEmpty() ) + return; int firstItemAdded = -1; -- 2.11.4.GIT