[banshee] Gio: prevent NRE when scanning for CD device (bgo#721203)



commit 20bacf9a3d06b2d136b474319f0b8224947bc4b8
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sun Dec 29 19:45:29 2013 +0100

    Gio: prevent NRE when scanning for CD device (bgo#721203)
    
    This is a similar fix to the one for BGO#699735 which consists
    in detecting a null value earlier before creating an instance
    of UdevMetadataSource class.
    
    This time we also throw ArgumentNullException now in the ctor
    of this class to fail faster when this situation happens,
    instead of failing when some code queries any property of
    an object of this class which happened to wrap a null value.
    
    [1] https://git.gnome.org/browse/banshee/commit/?h=stable-2.6&id=1f8d8746eb122449a3489901a87f8a15e54ae4cf

 .../LowLevel/RawBlockDevice.cs                     |    6 +++++-
 .../LowLevel/UdevMetadataSource.cs                 |    3 +++
 2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
index 3711945..51cb559 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
@@ -48,10 +48,14 @@ namespace Banshee.Hardware.Gio
                     if (volume == null) {
                         yield return null;
                     }
+                    var device = Manager.GudevDeviceFromGioVolume (volume);
+                    if (device == null) {
+                        yield return null;
+                    }
                     yield return new Volume (new RawVolume (volume,
                                                             Manager,
                                                             new GioVolumeMetadataSource (volume),
-                                                            new UdevMetadataSource 
(Manager.GudevDeviceFromGioVolume (volume))));
+                                                            new UdevMetadataSource (device)));
                 }
             }
         }
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
index 04cb12b..7d10193 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
@@ -71,6 +71,9 @@ namespace Banshee.Hardware.Gio
 
         public UdevMetadataSource (GUdev.Device device)
         {
+            if (device == null) {
+                throw new ArgumentNullException ("device");
+            }
             Device = device;
         }
 


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