Skip to content
Browse files

Fix crash when handling client service removal

When processing a ClientServiceRemoved event, we usually only have a
USN, the Service instance is null. So we need to handle this correctly
and get the service type from the USN.

This fixes the following bug reported against Banshee:
https://bugzilla.gnome.org/show_bug.cgi?id=671708
  • Loading branch information...
1 parent 3aaffa9 commit f74895e229fa2ba9bf1c17c4d5863dde42c8e679 @bl8 bl8 committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/Mono.Upnp/Mono.Upnp/Mono.Upnp/Client.cs
View
12 src/Mono.Upnp/Mono.Upnp/Mono.Upnp/Client.cs
@@ -139,14 +139,18 @@ void ClientServiceRemoved (object sender, Mono.Ssdp.ServiceArgs args)
var colon = args.Usn.IndexOf (':', 5);
var usn = colon == -1 ? args.Usn : args.Usn.Substring (0, colon);
+ var suffix = colon == -1 ? args.Usn : args.Usn.Substring (colon + 2);
+
+ var service_type = args.Service == null ? suffix : args.Service.ServiceType;
+ var locations = args.Service == null ? null : args.Service.Locations;
if (args.Usn.Contains (":device:")) {
- var type = DeviceType.Parse (args.Service.ServiceType);
- var device = new DeviceAnnouncement (this, type, usn, args.Service.Locations);
+ var type = DeviceType.Parse (service_type);
+ var device = new DeviceAnnouncement (this, type, usn, locations);
deviceHandler (device);
} else if (args.Usn.Contains (":service:")) {
- var type = ServiceType.Parse (args.Service.ServiceType);
- var service = new ServiceAnnouncement (this, type, usn, args.Service.Locations);
+ var type = ServiceType.Parse (service_type);
+ var service = new ServiceAnnouncement (this, type, usn, locations);
serviceHandler (service);
}
}

0 comments on commit f74895e

Please sign in to comment.
Something went wrong with that request. Please try again.