From 3ff56a6dde57b0109d16a186b65a3d2cdb4a7616 Mon Sep 17 00:00:00 2001 From: Ozan Tezcan Date: Fri, 24 Sep 2021 22:03:19 +0300 Subject: [PATCH] Fix crash due to free() call for a string literal in redis-benchmark (#9546) --- src/redis-benchmark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 6ae6ced92..36da5e32e 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -1421,6 +1421,7 @@ int parseOptions(int argc, char **argv) { config.keepalive = atoi(argv[++i]); } else if (!strcmp(argv[i],"-h")) { if (lastarg) goto invalid; + sdsfree(config.conn_info.hostip); config.conn_info.hostip = sdsnew(argv[++i]); } else if (!strcmp(argv[i],"-p")) { if (lastarg) goto invalid; @@ -1720,7 +1721,7 @@ int main(int argc, char **argv) { config.loop = 0; config.idlemode = 0; config.clients = listCreate(); - config.conn_info.hostip = "127.0.0.1"; + config.conn_info.hostip = sdsnew("127.0.0.1"); config.conn_info.hostport = 6379; config.hostsocket = NULL; config.tests = NULL;