From 41a32ea8d13a8db076d8e92fa0f0a5369f72dbd7 Mon Sep 17 00:00:00 2001 From: Pavel Punsky Date: Sat, 20 Sep 2025 18:42:21 -0700 Subject: [PATCH] Fix memory leak using libevent #1751 --- src/apps/common/apputils.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/apps/common/apputils.c b/src/apps/common/apputils.c index 786781b9..3b5949df 100644 --- a/src/apps/common/apputils.c +++ b/src/apps/common/apputils.c @@ -927,8 +927,8 @@ static char *_WTA(__in wchar_t *pszInBuf, __in int nInSize, __out char **pszOutB return NULL; } else { if (pszOutBuf != NULL) { - (*pszOutBuf)[*pnOutSize - 1] = '\0'; - return *pszOutBuf; + (*pszOutBuf)[*pnOutSize - 1] = '\0'; + return *pszOutBuf; } else { return NULL; } @@ -1344,11 +1344,11 @@ void build_base64_decoding_table(void) { char *table = (char *)calloc(256, sizeof(char)); if (table) { - for (size_t i = 0; i < 64; i++) { - table[(unsigned char)encoding_table[i]] = i; - } - decoding_table = table; + for (size_t i = 0; i < 64; i++) { + table[(unsigned char)encoding_table[i]] = i; } + decoding_table = table; +} } unsigned char *base64_decode(const char *data, size_t input_length, size_t *output_length) { @@ -1416,10 +1416,10 @@ const char *turn_get_ssl_method(SSL *ssl, const char *mdefault) { struct event_base *turn_event_base_new(void) { struct event_config *cfg = event_config_new(); - event_config_set_flag(cfg, EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST); - - return event_base_new_with_config(cfg); + struct event_base *base = event_base_new_with_config(cfg); + event_config_free(cfg); // Free the config after use to make valgrind happy + return base; } /////////// OAUTH /////////////////