r22022: - Clarify the comments
authorAndrew Bartlett <abartlet@samba.org>
Mon, 2 Apr 2007 05:53:34 +0000 (05:53 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:19:03 +0000 (12:19 -0500)
- make sure never to free an uninitialised variable

- ensure to free result on getpwnam_alloc failure

Andrew Bartlett
(This used to be commit 5fe3328e66661371182cc1c3b6e239797c3b4f93)

source3/auth/auth_sam.c
source3/auth/auth_util.c

index 31178a761ce8b13131838b4195aa67eefd619c5d..0fa68cbb87adebdd01726e66b294d47755955e8c 100644 (file)
@@ -263,8 +263,8 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       /* Can't use the talloc version here, because the returned struct gets
-          kept on the server_info */
+       /* the returned struct gets kept on the server_info, by means
+          of a steal further down */
 
        if ( !(sampass = samu_new( mem_ctx )) ) {
                return NT_STATUS_NO_MEMORY;
index 5c3bf7acceb7e966ce772f726f6278c87067109b..7891ce1599abe92ab72d014ba1e2e12c9e72b6d6 100644 (file)
@@ -562,13 +562,13 @@ NTSTATUS make_server_info_sam(auth_serversupplied_info **server_info,
        
 
        if ( !(result = make_server_info(NULL)) ) {
-               TALLOC_FREE(pwd);
                return NT_STATUS_NO_MEMORY;
        }
 
        if ( !(pwd = getpwnam_alloc(result, pdb_get_username(sampass))) ) {
                DEBUG(1, ("User %s in passdb, but getpwnam() fails!\n",
                          pdb_get_username(sampass)));
+               TALLOC_FREE(result);
                return NT_STATUS_NO_SUCH_USER;
        }