aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-22 19:49:02 +0100
committerMax Kellermann <max@duempel.org>2014-01-22 20:26:33 +0100
commit0fa98479adc40435ac91d385354f7b372f9ae44e (patch)
tree85abbe2f943c8c2d7ed70d095c64ef3faad26229 /src/db/upnp
parent02f2171010accc1e9473e2a12a51d79782ee0f52 (diff)
downloadmpd-0fa98479adc40435ac91d385354f7b372f9ae44e.tar.gz
mpd-0fa98479adc40435ac91d385354f7b372f9ae44e.tar.xz
mpd-0fa98479adc40435ac91d385354f7b372f9ae44e.zip
db/upnp: obtain char* from ixmlwrap::getFirstElementValue()
Fixes crash when there's no SearchCaps element.
Diffstat (limited to 'src/db/upnp')
-rw-r--r--src/db/upnp/ContentDirectoryService.cxx22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/db/upnp/ContentDirectoryService.cxx b/src/db/upnp/ContentDirectoryService.cxx
index b666716f7..d57f426ec 100644
--- a/src/db/upnp/ContentDirectoryService.cxx
+++ b/src/db/upnp/ContentDirectoryService.cxx
@@ -27,6 +27,7 @@
#include "Action.hxx"
#include "util/Error.hxx"
+#include <string.h>
#include <stdio.h>
ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
@@ -243,19 +244,22 @@ ContentDirectoryService::getSearchCapabilities(UpnpClient_Handle hdl,
return false;
}
- std::string tbuf = ixmlwrap::getFirstElementValue(response, "SearchCaps");
- ixmlDocument_free(response);
+ const char *s = ixmlwrap::getFirstElementValue(response, "SearchCaps");
+ if (s == nullptr || *s == 0) {
+ ixmlDocument_free(response);
+ return true;
+ }
- if (!tbuf.compare("*")) {
+ bool success = true;
+ if (strcmp(s, "*") == 0) {
result.insert(result.end(), "*");
- } else if (!tbuf.empty()) {
- if (!csvToStrings(tbuf.c_str(), result)) {
- error.Set(upnp_domain, "Bad response");
- return false;
- }
+ } else if (!csvToStrings(s, result)) {
+ error.Set(upnp_domain, "Bad response");
+ success = false;
}
- return true;
+ ixmlDocument_free(response);
+ return success;
}
bool