[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [amarok] /: scriptable service: fix a crash due to double deletion of an object
From:       Matěj_Laitl <matej () laitl ! cz>
Date:       2014-11-02 10:13:47
Message-ID: E1XksAN-0001Kl-0Q () scm ! kde ! org
[Download RAW message or body]

Git commit 7e9e0710daecdb2c6372a699e9af967f485c66c0 by Matěj Laitl.
Committed on 02/11/2014 at 10:01.
Pushed by laitl into branch 'master'.

scriptable service: fix a crash due to double deletion of an object

Thanks go to Ralf Engels for pointing out the problematic code.

The problem is IMO not directly in insertItem() using KSharedPtr, but
in addTrack() which creates a KSharedPtr out of a track pointer, but at
the same time calls delete on the track pointer in some circumstances.

Once a pointer is KSharedPtr-managed, delete must not be used.

I've kept KSharedPtr for track in insertItem(). While using it is a bit
inconsistent wrt. surrounding code, it should have no effect (the crash
is IMO caused by addTrack() code alone). It feels more correct as it
prevents a hypothetical (currently unreachable) memory leak.

Interested folks, please test whether this really fixes bug 334479 for
you.

BUG: 334479
FIXED-IN: 2.9

M  +1    -0    ChangeLog
M  +0    -3    src/services/scriptable/ScriptableService.cpp

http://commits.kde.org/amarok/7e9e0710daecdb2c6372a699e9af967f485c66c0

diff --git a/ChangeLog b/ChangeLog
index 72e0b07..eeff0d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@ VERSION 2.8.1
      compilers currently supported by KDE.
 
   BUGFIXES:
+   * Fix a crash when searching the Icecast directory. (BR 334479)
    * Correct wrong lowercase for FLAC and MP3. Patch provided by Duilio Felix (BR \
                339495)
    * Collection Browser no longer excessively expands the tree. (BR 300557)
    * Properly calculate and store Aft tags in mp4 files.  Patch By Stefano
diff --git a/src/services/scriptable/ScriptableService.cpp \
b/src/services/scriptable/ScriptableService.cpp index a4ffa7e..2222ed6 100644
--- a/src/services/scriptable/ScriptableService.cpp
+++ b/src/services/scriptable/ScriptableService.cpp
@@ -241,7 +241,6 @@ int ScriptableService::addTrack( ScriptableServiceTrack * track )
     if ( m_levels > 1 ) {
 
         if ( !m_ssAlbumIdMap.contains( albumId ) ){
-            delete track;
             return -1;
         }
 
@@ -258,7 +257,6 @@ int ScriptableService::addTrack( ScriptableServiceTrack * track )
      if ( m_levels > 2 ) {
 
          if ( !m_ssArtistIdMap.contains( artistId ) ) {
-             delete track;
              return -1;
          }
 
@@ -273,7 +271,6 @@ int ScriptableService::addTrack( ScriptableServiceTrack * track )
      if ( m_levels == 4) {
          
          if ( !m_ssGenreIdMap.contains( genreId ) ) {
-             delete track;
              return -1;
          }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic