From 603265dac2f96e484d99ca08b73abbea8e60e472 Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 8 May 2025 13:45:28 +0300 Subject: [PATCH] nfqws: do not realloc hostname in ipcache if it's the same --- nfq/desync.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nfq/desync.c b/nfq/desync.c index d14ad14..3ec813a 100644 --- a/nfq/desync.c +++ b/nfq/desync.c @@ -810,13 +810,16 @@ static bool ipcache_put_hostname(const struct in_addr *a4, const struct in6_addr DLOG_ERR("ipcache_put_hostname: out of memory\n"); return false; } - free(ipc->hostname); - if (!(ipc->hostname = strdup(hostname))) + if (!ipc->hostname || strcmp(ipc->hostname,hostname)) { - DLOG_ERR("ipcache_put_hostname: out of memory\n"); - return false; + free(ipc->hostname); + if (!(ipc->hostname = strdup(hostname))) + { + DLOG_ERR("ipcache_put_hostname: out of memory\n"); + return false; + } + DLOG("hostname cached: %s\n", hostname); } - DLOG("hostname cached: %s\n", hostname); return true; } static bool ipcache_get_hostname(const struct in_addr *a4, const struct in6_addr *a6, char *hostname, size_t hostname_buf_len)