smbd: free talloc context if no quota records are available
authorUri Simchoni <uri@samba.org>
Sun, 18 Sep 2016 08:05:23 +0000 (11:05 +0300)
committerJeremy Allison <jra@samba.org>
Tue, 4 Oct 2016 00:00:22 +0000 (02:00 +0200)
When generating a list of user quota records, free the memory
context that controls this list if the list is empty. Otherwise,
the context remains unreferenced and memory is leaked.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12289

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/ntquotas.c

index 93f4a2ae12fe905cd886ffdb4480d6ef072648e9..4acfa5057ed0201f17271c08d7bb0e742d8a2b95 100644 (file)
@@ -226,6 +226,9 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
        }
        endpwent();
 
+       if (*qt_list == NULL) {
+               TALLOC_FREE(mem_ctx);
+       }
        return 0;
 }