From 4de4fcf280648519239927d408624ea34953c0e0 Mon Sep 17 00:00:00 2001 From: Binbin Date: Wed, 11 Oct 2023 02:45:38 -0500 Subject: [PATCH] Fix redis-cli pubsub_mode and connect minor prompt / crash issue (#12571) When entering pubsub mode and using the redis-cli only connect command, we need to reset pubsub_mode because we switch to a different connection. This will affect the prompt when the connection is successful, and redis-cli will crash when the connect fails: ``` 127.0.0.1:6379> subscribe ch 1) "subscribe" 2) "ch" 3) (integer) 1 127.0.0.1:6379(subscribed mode)> connect 127.0.0.1 6380 127.0.0.1:6380(subscribed mode)> ping PONG 127.0.0.1:6380(subscribed mode)> connect a b Could not connect to Redis at a:0: Name or service not known Segmentation fault ``` --- src/redis-cli.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/redis-cli.c b/src/redis-cli.c index caa996dfa..34f033947 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1657,6 +1657,7 @@ static int cliConnect(int flags) { redisFree(context); config.dbnum = 0; config.in_multi = 0; + config.pubsub_mode = 0; cliRefreshPrompt(); }