[banshee] [mtp] Workaround a sigsegv bug in libmtp.



commit 48b5d53e0cf08e229af072780da9ecce9943a0fb
Author: Alan McGovern <alan mcgovern gmail com>
Date:   Mon Sep 13 01:01:42 2010 +0100

    [mtp] Workaround a sigsegv bug in libmtp.
    
    Ensure that Album.Name is always non-null so libmtp doesn't blow up
    calling strlen on a null pointer. Fixes #629373.

 .../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs   |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index ae222c5..a2263b0 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -337,7 +337,11 @@ namespace Banshee.Dap.Mtp
                 if (!video) {
                     string key = MakeAlbumKey (track.AlbumArtist, track.AlbumTitle);
                     if (!album_cache.ContainsKey (key)) {
-                        Album album = new Album (mtp_device, track.AlbumTitle, track.AlbumArtist, track.Genre, track.Composer);
+                        // LIBMTP 1.0.3 BUG WORKAROUND
+                        // In libmtp.c the 'LIBMTP_Create_New_Album' function invokes 'create_new_abstract_list'.
+                        // The latter calls strlen on the 'name' parameter without null checking. If AlbumTitle is
+                        // null, this causes a sigsegv. Lets be safe and always pass non-null values.
+                        Album album = new Album (mtp_device, track.AlbumTitle ?? "", track.AlbumArtist ?? "", track.Genre ?? "", track.Composer ?? "");
                         album.AddTrack (mtp_track);
 
                         if (supports_jpegs && can_sync_albumart) {



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