From 1b5448ede4b0a0ed70d10dee025b20d318a007b0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 20 Nov 2020 16:35:48 -0500 Subject: [PATCH] Handle there being no services in the response --- onvif/modules/lib/ONVIF/Client.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/onvif/modules/lib/ONVIF/Client.pm b/onvif/modules/lib/ONVIF/Client.pm index 9676dff85..945e96075 100644 --- a/onvif/modules/lib/ONVIF/Client.pm +++ b/onvif/modules/lib/ONVIF/Client.pm @@ -117,12 +117,15 @@ sub get_service_urls { } ); if ( $result ) { - foreach my $svc ( @{ $result->get_Service() } ) { - my $short_name = $namespace_map{$svc->get_Namespace()}; - my $url_svc = $svc->get_XAddr()->get_value(); - if ( defined $short_name && defined $url_svc ) { - #print "Got $short_name service\n"; - $self->set_service($short_name, 'url', $url_svc); + my $services = $result->get_Service(); + if ( $services ) { + foreach my $svc ( @{ $services } ) { + my $short_name = $namespace_map{$svc->get_Namespace()}; + my $url_svc = $svc->get_XAddr()->get_value(); + if ( defined $short_name && defined $url_svc ) { + #print "Got $short_name service\n"; + $self->set_service($short_name, 'url', $url_svc); + } } } #} else {