From bf9352fb268384f428332b0aabeaefcc9c1e4843 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 22 Jan 2014 21:09:05 +0100 Subject: [PATCH] db/upnp: free responses manually --- src/db/upnp/ContentDirectoryService.cxx | 27 ++++++------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/db/upnp/ContentDirectoryService.cxx b/src/db/upnp/ContentDirectoryService.cxx index 9068b2e30..d4e5fec59 100644 --- a/src/db/upnp/ContentDirectoryService.cxx +++ b/src/db/upnp/ContentDirectoryService.cxx @@ -48,18 +48,6 @@ ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, } } -class DirBResFree { -public: - IXML_Document **rspp; - DirBResFree(IXML_Document **_rspp) - :rspp(_rspp) {} - ~DirBResFree() - { - if (*rspp) - ixmlDocument_free(*rspp); - } -}; - static bool ReadResultTag(UPnPDirContent &dirbuf, IXML_Document *response, Error &error) { @@ -106,8 +94,6 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl, return false; } - DirBResFree cleaner(&response); - const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); didreadp = value != nullptr ? ParseUnsigned(value) @@ -117,10 +103,9 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl, if (value != nullptr) totalp = ParseUnsigned(value); - if (!ReadResultTag(dirbuf, response, error)) - return false; - - return true; + bool success = ReadResultTag(dirbuf, response, error); + ixmlDocument_free(response); + return success; } bool @@ -183,8 +168,6 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, return false; } - DirBResFree cleaner(&response); - const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); const unsigned count = value != nullptr @@ -197,7 +180,9 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, if (value != nullptr) total = ParseUnsigned(value); - if (!ReadResultTag(dirbuf, response, error)) + bool success = ReadResultTag(dirbuf, response, error); + ixmlDocument_free(response); + if (!success) return false; if (count == 0)