[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#377704: Fixed crashes



It seems like there is a bug in the logic in database/song_set.cpp.
The code assumes that the set is setup for sorting, but it isn't yet
(DoSort is false, and SortField, SecondarySortField and
TertiarySortField aren't initialized). So the call to 'getLess' is
failing because 'SortField' has an invalid value.

I've made the change below and my madplay installation is no longer crashing:

diff --git a/madman-0.94beta1.20060611/database/song_set.cpp
b/madman-0.94beta1.20060611/database/song_set.cpp
index 19209c2..3326fb6 100644
--- a/madman-0.94beta1.20060611/database/song_set.cpp
+++ b/madman-0.94beta1.20060611/database/song_set.cpp
@@ -527,13 +527,21 @@ void tSearchSongSet::noticeSongModified(const
tSong *song, tSongField field)

 void tSearchSongSet::addSongToSortedSongList(tSongList &sl, const tSong *song)
 {
-  tLessContainer less(getLess(SortField,
-                              SecondarySortField,
-                              TertiarySortField));
+  // Only attempt to insert into a sorted position if sorting has been setup:
+  if (DoSort)
+  {
+    // Sorting has been setup, insert into the correct position:
+    tLessContainer less(getLess(SortField,
+                                SecondarySortField,
+                                TertiarySortField));

-  tSongList::iterator at = lower_bound(sl.begin(), sl.end(),
-                                       const_cast<tSong *>(song), less);
-  sl.insert(at, const_cast<tSong *>(song));
+    tSongList::iterator at = lower_bound(sl.begin(), sl.end(),
+                                         const_cast<tSong *>(song), less);
+    sl.insert(at, const_cast<tSong *>(song));
+  }
+  else
+    // No sorting setup, so just append to the end:
+    sl.push_back(const_cast<tSong *>(song));
 }




Reply to: