From 9db2c84984739008c5cd911943ea97775fc32045 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Wed, 30 Jan 2019 11:50:30 +0100
Subject: [PATCH] ACL: free memory leak when freeing subcommands array.

---
 src/acl.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/acl.c b/src/acl.c
index 5f418517..da7c0bd4 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -385,8 +385,13 @@ void ACLResetSubcommandsForCommand(user *u, unsigned long id) {
  * for the user. */
 void ACLResetSubcommands(user *u) {
     if (u->allowed_subcommands == NULL) return;
-    for (int j = 0; j < USER_COMMAND_BITS_COUNT; j++)
-        if (u->allowed_subcommands[j]) zfree(u->allowed_subcommands[j]);
+    for (int j = 0; j < USER_COMMAND_BITS_COUNT; j++) {
+        if (u->allowed_subcommands[j]) {
+            for (int i = 0; u->allowed_subcommands[j][i]; i++)
+                sdsfree(u->allowed_subcommands[j][i]);
+            zfree(u->allowed_subcommands[j]);
+        }
+    }
     zfree(u->allowed_subcommands);
     u->allowed_subcommands = NULL;
 }