upnp: fix crash when upnp_server was NULL
authormontellese <montellese@xbmc.org>
Thu, 5 Jun 2014 05:19:27 +0000 (07:19 +0200)
committermontellese <montellese@xbmc.org>
Thu, 5 Jun 2014 05:19:27 +0000 (07:19 +0200)
xbmc/network/upnp/UPnPInternal.cpp

index 694290e..b28603e 100644 (file)
@@ -572,34 +572,36 @@ BuildObject(CFileItem&                    item,
         }
     }
 
-    // determine the correct artwork for this item
-    if (!thumb_loader.IsNull())
-        thumb_loader->LoadItem(&item);
-
-    // finally apply the found artwork
-    thumb = item.GetArt("thumb");
-    if (upnp_server && !thumb.empty()) {
-        PLT_AlbumArtInfo art;
-        art.uri = upnp_server->BuildSafeResourceUri(
-            rooturi,
-            (*ips.GetFirstItem()).ToString(),
-            CTextureUtils::GetWrappedImageURL(thumb).c_str());
-
-        // Set DLNA profileID by extension, defaulting to JPEG.
-        if (URIUtils::HasExtension(thumb, ".png")) {
-            art.dlna_profile = "PNG_TN";
-        } else {
-            art.dlna_profile = "JPEG_TN";
+    if (upnp_server) {
+        // determine the correct artwork for this item
+        if (!thumb_loader.IsNull())
+            thumb_loader->LoadItem(&item);
+
+        // finally apply the found artwork
+        thumb = item.GetArt("thumb");
+        if (!thumb.empty()) {
+            PLT_AlbumArtInfo art;
+            art.uri = upnp_server->BuildSafeResourceUri(
+                rooturi,
+                (*ips.GetFirstItem()).ToString(),
+                CTextureUtils::GetWrappedImageURL(thumb).c_str());
+
+            // Set DLNA profileID by extension, defaulting to JPEG.
+            if (URIUtils::HasExtension(thumb, ".png")) {
+                art.dlna_profile = "PNG_TN";
+            } else {
+                art.dlna_profile = "JPEG_TN";
+            }
+            object->m_ExtraInfo.album_arts.Add(art);
         }
-        object->m_ExtraInfo.album_arts.Add(art);
-    }
 
-    for (CGUIListItem::ArtMap::const_iterator itArtwork = item.GetArt().begin(); itArtwork != item.GetArt().end(); ++itArtwork) {
-        if (!itArtwork->first.empty() && !itArtwork->second.empty()) {
-            std::string wrappedUrl = CTextureUtils::GetWrappedImageURL(itArtwork->second);
-            object->m_XbmcInfo.artwork.Add(itArtwork->first.c_str(),
-              upnp_server->BuildSafeResourceUri(rooturi, (*ips.GetFirstItem()).ToString(), wrappedUrl.c_str()));
-            upnp_server->AddSafeResourceUri(object, rooturi, ips, wrappedUrl.c_str(), ("xbmc.org:*:" + itArtwork->first + ":*").c_str());
+        for (CGUIListItem::ArtMap::const_iterator itArtwork = item.GetArt().begin(); itArtwork != item.GetArt().end(); ++itArtwork) {
+            if (!itArtwork->first.empty() && !itArtwork->second.empty()) {
+                std::string wrappedUrl = CTextureUtils::GetWrappedImageURL(itArtwork->second);
+                object->m_XbmcInfo.artwork.Add(itArtwork->first.c_str(),
+                  upnp_server->BuildSafeResourceUri(rooturi, (*ips.GetFirstItem()).ToString(), wrappedUrl.c_str()));
+                upnp_server->AddSafeResourceUri(object, rooturi, ips, wrappedUrl.c_str(), ("xbmc.org:*:" + itArtwork->first + ":*").c_str());
+            }
         }
     }