Skip to content

Commit

Permalink
Fix crash when handling client service removal
Browse files Browse the repository at this point in the history
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
bl8 committed Mar 10, 2012
1 parent 3aaffa9 commit f74895e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Mono.Upnp/Mono.Upnp/Mono.Upnp/Client.cs
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit f74895e

Please sign in to comment.