From 4b9b128c4951405031fc94ca5ed172c12a846eb5 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Mon, 28 Jan 2019 12:11:11 +0100
Subject: [PATCH] ACL: remove leak when removing passwords/patterns.

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

diff --git a/src/acl.c b/src/acl.c
index b6f1d0ab..9503aec3 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -134,6 +134,11 @@ int ACLListMatchSds(void *a, void *b) {
     return sdscmp(a,b) == 0;
 }
 
+/* Method to free list elements from ACL users password/ptterns lists. */
+void ACLListFreeSds(void *item) {
+    sdsfree(item);
+}
+
 /* Create a new user with the specified name, store it in the list
  * of users (the Users global radix tree), and returns a reference to
  * the structure representing the user.
@@ -148,7 +153,9 @@ user *ACLCreateUser(const char *name, size_t namelen) {
     u->passwords = listCreate();
     u->patterns = listCreate();
     listSetMatchMethod(u->passwords,ACLListMatchSds);
+    listSetFreeMethod(u->passwords,ACLListFreeSds);
     listSetMatchMethod(u->patterns,ACLListMatchSds);
+    listSetFreeMethod(u->patterns,ACLListFreeSds);
     memset(u->allowed_commands,0,sizeof(u->allowed_commands));
     raxInsert(Users,(unsigned char*)name,namelen,u,NULL);
     return u;