mirror of
http://github.com/valkey-io/valkey
synced 2024-11-21 16:46:15 +00:00
Set fields to NULL after free in freeClient() (#1279)
Null out several references after freeing the object in `freeClient()`. This is just to make the code more safe, to protect against use-after-free for future changes. Signed-off-by: Qu Chen <quchen@amazon.com>
This commit is contained in:
parent
0b5b2c7484
commit
9300a7ebc8
@ -1731,6 +1731,7 @@ void freeClient(client *c) {
|
||||
/* UNWATCH all the keys */
|
||||
unwatchAllKeys(c);
|
||||
listRelease(c->watched_keys);
|
||||
c->watched_keys = NULL;
|
||||
|
||||
/* Unsubscribe from all the pubsub channels */
|
||||
pubsubUnsubscribeAllChannels(c, 0);
|
||||
@ -1738,16 +1739,22 @@ void freeClient(client *c) {
|
||||
pubsubUnsubscribeAllPatterns(c, 0);
|
||||
unmarkClientAsPubSub(c);
|
||||
dictRelease(c->pubsub_channels);
|
||||
c->pubsub_channels = NULL;
|
||||
dictRelease(c->pubsub_patterns);
|
||||
c->pubsub_patterns = NULL;
|
||||
dictRelease(c->pubsubshard_channels);
|
||||
c->pubsubshard_channels = NULL;
|
||||
|
||||
/* Free data structures. */
|
||||
listRelease(c->reply);
|
||||
c->reply = NULL;
|
||||
zfree(c->buf);
|
||||
c->buf = NULL;
|
||||
freeReplicaReferencedReplBuffer(c);
|
||||
freeClientArgv(c);
|
||||
freeClientOriginalArgv(c);
|
||||
if (c->deferred_reply_errors) listRelease(c->deferred_reply_errors);
|
||||
c->deferred_reply_errors = NULL;
|
||||
#ifdef LOG_REQ_RES
|
||||
reqresReset(c, 1);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user