[banshee] Mtp: prevent earlier the use of NULL as MtpDevice in AbstractTrackList



commit e8f34fb146294e774f54aa66a492a1cc1ca098a3
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Mon Jul 28 20:18:40 2014 +0200

    Mtp: prevent earlier the use of NULL as MtpDevice in AbstractTrackList
    
    In order to track down the source of bgo#733883, it's better to
    throw ArgumentNullException earlier at creation time than later
    causing a NullReferenceException when the field is going to be
    used.
    
    (In order to check against NULL only once, this commit chains 2
    constructors together.)

 src/Libraries/Mtp/Mtp/AbstractTrackList.cs |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
index f38530b..c2cf3dc 100644
--- a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
+++ b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
@@ -57,13 +57,19 @@ namespace Mtp
 
         protected AbstractTrackList (MtpDevice device)
         {
+            if (device == null) {
+                throw new ArgumentNullException ("device");
+            }
+
             this.device = device;
-            track_ids = new List<uint> ();
+
+            if (track_ids == null) {
+                track_ids = new List<uint> ();
+            }
         }
 
-        internal AbstractTrackList (MtpDevice device, IntPtr tracks, uint count)
+        internal AbstractTrackList (MtpDevice device, IntPtr tracks, uint count) : this (device)
         {
-            this.device = device;
             this.saved = true;
             this.track_ids = new List<uint> ();
 


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