From 6c41e8f63f6ef0eab548d49b75eb18e465009a17 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 22 Jan 2014 21:03:45 +0100 Subject: db/upnp: check offset 0 && offset < total); return true; } @@ -139,10 +134,9 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, UPnPDirContent &dirbuf, Error &error) { - unsigned offset = 0; - unsigned total = 1000;// Updated on first read. + unsigned offset = 0, total = -1, count; - while (offset < total) { + do { char ofbuf[100]; sprintf(ofbuf, "%d", offset); @@ -173,7 +167,7 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); - const unsigned count = value != nullptr + count = value != nullptr ? ParseUnsigned(value) : 0; @@ -187,10 +181,7 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, ixmlDocument_free(response); if (!success) return false; - - if (count == 0) - break; - } + } while (count > 0 && offset < total); return true; } -- cgit v1.2.3