From 7106137d4a7861ed1f8cb9ed5637274a88157b17 Mon Sep 17 00:00:00 2001 From: jiayun Date: Mon, 17 Jun 2024 11:33:13 +0800 Subject: [PATCH] fix: memeory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sds和char*混用,导致sdsnewlen(master->addr, sdslen(master->addr))内存泄漏 --- src/rmt_redis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rmt_redis.c b/src/rmt_redis.c index dfc58e6..ee6517e 100644 --- a/src/rmt_redis.c +++ b/src/rmt_redis.c @@ -261,7 +261,7 @@ int redis_node_init(redis_node *rnode, const char *addr, redis_group *rgroup) rnode->owner = rgroup; - rnode->addr = rmt_strdup(addr); + rnode->addr = sdsdup((sds) addr); if (rnode->addr == NULL) { log_error("ERROR: Out of memory"); goto error; @@ -389,7 +389,7 @@ void redis_node_deinit(redis_node *rnode) } if (rnode->addr != NULL) { - free(rnode->addr); + sdsfree(rnode->addr); rnode->addr = NULL; }