Memory fixes
This commit is contained in:
+9
-1
@@ -20,6 +20,10 @@ IrcUri::~IrcUri(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CURL_FOUND
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
const std::optional<std::string> IrcUri::get_server(void) const {
|
const std::optional<std::string> IrcUri::get_server(void) const {
|
||||||
#ifdef CURL_FOUND
|
#ifdef CURL_FOUND
|
||||||
char *server;
|
char *server;
|
||||||
@@ -27,7 +31,9 @@ const std::optional<std::string> IrcUri::get_server(void) const {
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return server;
|
std::string result(server);
|
||||||
|
curl_free(server);
|
||||||
|
return result;
|
||||||
#else
|
#else
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
#endif // CURL_FOUND
|
#endif // CURL_FOUND
|
||||||
@@ -42,6 +48,7 @@ const std::optional<std::string> IrcUri::get_entity(void) const {
|
|||||||
if (rc)
|
if (rc)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
output = entity;
|
output = entity;
|
||||||
|
curl_free(entity);
|
||||||
if (!output.empty())
|
if (!output.empty())
|
||||||
output.erase(0, 1);
|
output.erase(0, 1);
|
||||||
if (output.empty()) {
|
if (output.empty()) {
|
||||||
@@ -49,6 +56,7 @@ const std::optional<std::string> IrcUri::get_entity(void) const {
|
|||||||
if (rc)
|
if (rc)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
output = entity;
|
output = entity;
|
||||||
|
curl_free(entity);
|
||||||
output.insert(0, 1, '#');
|
output.insert(0, 1, '#');
|
||||||
}
|
}
|
||||||
return IrcUri::parse_entity(output);
|
return IrcUri::parse_entity(output);
|
||||||
|
|||||||
Reference in New Issue
Block a user