diff --git a/src/irc/irc_uri.cpp b/src/irc/irc_uri.cpp index fc542f8..e5ea564 100644 --- a/src/irc/irc_uri.cpp +++ b/src/irc/irc_uri.cpp @@ -20,6 +20,10 @@ IrcUri::~IrcUri(void) { #endif } +#ifdef CURL_FOUND +#include +#endif + const std::optional IrcUri::get_server(void) const { #ifdef CURL_FOUND char *server; @@ -27,7 +31,9 @@ const std::optional IrcUri::get_server(void) const { if (rc) { return std::nullopt; } - return server; + std::string result(server); + curl_free(server); + return result; #else return std::nullopt; #endif // CURL_FOUND @@ -42,6 +48,7 @@ const std::optional IrcUri::get_entity(void) const { if (rc) return std::nullopt; output = entity; + curl_free(entity); if (!output.empty()) output.erase(0, 1); if (output.empty()) { @@ -49,6 +56,7 @@ const std::optional IrcUri::get_entity(void) const { if (rc) return std::nullopt; output = entity; + curl_free(entity); output.insert(0, 1, '#'); } return IrcUri::parse_entity(output);