--- a/libupnpp/control/discovery.cxx
+++ b/libupnpp/control/discovery.cxx
@@ -223,9 +223,9 @@
             char contentType[LINE_SIZE];
             int code = UpnpDownloadUrlItem(tsk->url.c_str(), &buf, contentType);
             if (code != UPNP_E_SUCCESS) {
-                LOGERR(LibUPnP::errAsString(
-                           "discoExplorer:UpnpDownloadUrlItem", code) << 
+                LOGERR(LibUPnP::errAsString("discoExplorer:UpnpDownloadUrlItem", code) << 
                        " trying to fetch " << tsk->url << endl);
+                delete tsk;
                 continue;
             }
             string sdesc(buf);