Memory fixes

This commit is contained in:
Stephen Paul Weber
2026-09-23 21:12:31 -05:00
parent 32485f0593
commit ff173a8ea3
+9 -1
View File
@@ -20,6 +20,10 @@ IrcUri::~IrcUri(void) {
#endif
}
#ifdef CURL_FOUND
#include <curl/curl.h>
#endif
const std::optional<std::string> IrcUri::get_server(void) const {
#ifdef CURL_FOUND
char *server;
@@ -27,7 +31,9 @@ const std::optional<std::string> 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<std::string> 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<std::string> IrcUri::get_entity(void) const {
if (rc)
return std::nullopt;
output = entity;
curl_free(entity);
output.insert(0, 1, '#');
}
return IrcUri::parse_entity(output);