ACL: Fix memory leak in ACLResetSubcommandsForCommand().

This commit fixes bug reported at #5998. Thanks to @tomcat1102.
This commit is contained in:
antirez 2019-04-08 18:08:37 +02:00
parent f8a9708aa7
commit c24e32041b
2 changed files with 3 additions and 1 deletions

View File

@ -542,6 +542,8 @@ struct redisCommand *ACLLookupCommand(const char *name) {
* and command ID. */
void ACLResetSubcommandsForCommand(user *u, unsigned long id) {
if (u->allowed_subcommands && u->allowed_subcommands[id]) {
for (int i = 0; u->allowed_subcommands[id][i]; i++)
sdsfree(u->allowed_subcommands[id][i]);
zfree(u->allowed_subcommands[id]);
u->allowed_subcommands[id] = NULL;
}

View File

@ -109,7 +109,7 @@ start_server {tags {"acl"}} {
assert_match {*+acl*} $cmdstr
}
test {ACL regression: memory leaks adding / removing subcommands} {
test {ACL #5998 regression: memory leaks adding / removing subcommands} {
r AUTH default ""
r ACL setuser newuser reset -debug +debug|a +debug|b +debug|c
r ACL setuser newuser -debug