From 984f5b7e29d86590b63a2efe7d480c18b9ac947b Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 8 May 2019 13:49:32 +0200 Subject: [PATCH] Fixed file descriptor leak in Downloader class --- lib/downloader.cpp | 7 +++++++ lib/downloader.h | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/downloader.cpp b/lib/downloader.cpp index c45ed90f..3168f9e5 100644 --- a/lib/downloader.cpp +++ b/lib/downloader.cpp @@ -65,6 +65,13 @@ namespace HTTP{ return S; } + Downloader::~Downloader(){ +#ifdef SSL + if (ssl){S_SSL.close();} +#endif + S.close(); + } + /// Sends a request for the given URL, does no waiting. void Downloader::doRequest(const HTTP::URL &link, const std::string &method, const std::string &body){ diff --git a/lib/downloader.h b/lib/downloader.h index 35eef078..8ab1ab15 100644 --- a/lib/downloader.h +++ b/lib/downloader.h @@ -5,6 +5,7 @@ namespace HTTP{ class Downloader{ public: Downloader(); + ~Downloader(); std::string &data(); const std::string &const_data() const; void doRequest(const HTTP::URL &link, const std::string &method = "",