Commit 0fa98479 authored by Max Kellermann's avatar Max Kellermann

db/upnp: obtain char* from ixmlwrap::getFirstElementValue()

Fixes crash when there's no SearchCaps element.
parent 02f21710
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "Action.hxx" #include "Action.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include <string.h>
#include <stdio.h> #include <stdio.h>
ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
...@@ -243,19 +244,22 @@ ContentDirectoryService::getSearchCapabilities(UpnpClient_Handle hdl, ...@@ -243,19 +244,22 @@ ContentDirectoryService::getSearchCapabilities(UpnpClient_Handle hdl,
return false; return false;
} }
std::string tbuf = ixmlwrap::getFirstElementValue(response, "SearchCaps"); const char *s = ixmlwrap::getFirstElementValue(response, "SearchCaps");
ixmlDocument_free(response); if (s == nullptr || *s == 0) {
ixmlDocument_free(response);
return true;
}
if (!tbuf.compare("*")) { bool success = true;
if (strcmp(s, "*") == 0) {
result.insert(result.end(), "*"); result.insert(result.end(), "*");
} else if (!tbuf.empty()) { } else if (!csvToStrings(s, result)) {
if (!csvToStrings(tbuf.c_str(), result)) { error.Set(upnp_domain, "Bad response");
error.Set(upnp_domain, "Bad response"); success = false;
return false;
}
} }
return true; ixmlDocument_free(response);
return success;
} }
bool bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment