From d8fa7a6a67eaeb66aa79bce3cb092d521b673b48 Mon Sep 17 00:00:00 2001 From: peak3d Date: Tue, 23 Apr 2019 22:19:19 +0200 Subject: [PATCH] CGUIDialogMediaBrowser: Fix usage of wrong item index --- xbmc/dialogs/GUIDialogMediaSource.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp index 86fae937041d4..d152b81edc201 100644 --- a/xbmc/dialogs/GUIDialogMediaSource.cpp +++ b/xbmc/dialogs/GUIDialogMediaSource.cpp @@ -229,15 +229,16 @@ void CGUIDialogMediaSource::OnMediaSourceChanged(const std::string& type, const void CGUIDialogMediaSource::OnPathBrowse(int item) { - if (item < 0 || item > m_paths->Size()) return; + if (item < 0 || item >= m_paths->Size()) return; // Browse is called. Open the filebrowser dialog. // Ignore current path is best at this stage?? - std::string path; + std::string path = m_paths->Get(item)->GetPath(); bool allowNetworkShares(m_type != "programs"); VECSOURCES extraShares; - if (m_name != CUtil::GetTitleFromPath(m_paths->Get(item)->GetPath())) + if (m_name != CUtil::GetTitleFromPath(path)) m_bNameChanged = true; + path.clear(); std::string strDevices = g_localizeStrings.Get(33040); //"% Devices" @@ -550,7 +551,7 @@ int CGUIDialogMediaSource::GetSelectedItem() CGUIMessage message(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_PATH); OnMessage(message); int value = message.GetParam1(); - if (value < 0 || value > m_paths->Size()) return 0; + if (value < 0 || value >= m_paths->Size()) return 0; return value; }