lib/{curl,upnp}: add more exception handlers

Bugs found by Coverity.
This commit is contained in:
Max Kellermann 2017-11-14 20:05:44 +01:00
parent e2c81aa9ea
commit 1040b85785
5 changed files with 25 additions and 13 deletions

View File

@ -72,7 +72,7 @@ CurlRequest::~CurlRequest() noexcept
}
void
CurlRequest::Start() noexcept
CurlRequest::Start()
{
assert(!registered);

View File

@ -91,7 +91,7 @@ public:
*
* This method must be called in the event loop thread.
*/
void Start() noexcept;
void Start();
/**
* Unregister this request via CurlGlobal::Remove().

View File

@ -174,15 +174,19 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) noexcept
{
if (isMSDevice(disco->DeviceType) ||
isCDService(disco->ServiceType)) {
auto *downloader = new Downloader(*this, *disco);
try {
downloader->Start();
} catch (...) {
BlockingCall(GetEventLoop(), [downloader](){
downloader->Destroy();
});
auto *downloader = new Downloader(*this, *disco);
try {
downloader->Start();
} catch (...) {
BlockingCall(GetEventLoop(), [downloader](){
downloader->Destroy();
});
throw;
}
} catch (...) {
LogError(std::current_exception());
return UPNP_E_SUCCESS;
}
@ -251,7 +255,7 @@ UPnPDeviceDirectory::ExpireDevices()
UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop,
UpnpClient_Handle _handle,
UPnPDiscoveryListener *_listener) noexcept
UPnPDiscoveryListener *_listener)
:curl(event_loop), handle(_handle),
listener(_listener)
{

View File

@ -110,7 +110,11 @@ class UPnPDeviceDirectory final : UpnpCallback {
private:
void OnDeferredStart() noexcept {
request.Start();
try {
request.Start();
} catch (...) {
OnError(std::current_exception());
}
}
/* virtual methods from CurlResponseHandler */
@ -147,7 +151,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
public:
UPnPDeviceDirectory(EventLoop &event_loop, UpnpClient_Handle _handle,
UPnPDiscoveryListener *_listener=nullptr) noexcept;
UPnPDiscoveryListener *_listener=nullptr);
~UPnPDeviceDirectory() noexcept;
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;

View File

@ -140,7 +140,11 @@ private:
void OnDeferredStart() noexcept {
assert(!done);
request.Start();
try {
request.Start();
} catch (...) {
OnError(std::current_exception());
}
}
/* virtual methods from CurlResponseHandler */