s3: Fix reference to freed memory in pam_winbind.
authorBo Yang <boyang@samba.org>
Wed, 14 Oct 2009 20:31:26 +0000 (04:31 +0800)
committerKarolin Seeger <kseeger@samba.org>
Thu, 26 Nov 2009 10:39:20 +0000 (11:39 +0100)
Signed-off-by: Bo Yang <boyang@samba.org>
(cherry picked from commit a94f0a5d8b2fa10972aef379a7137817c2ec0deb)

nsswitch/pam_winbind.c

index 324bede9ea38ec3854c050cdc80081dde059755f..a37ea7f78aa988031c31a581c0513c4b2ef429a6 100644 (file)
@@ -981,6 +981,7 @@ static bool winbind_name_to_sid_string(struct pwb_context *ctx,
                                       int sid_list_buffer_size)
 {
        const char* sid_string;
+       char *sid_str;
 
        /* lookup name? */
        if (IS_SID_STRING(name)) {
@@ -989,7 +990,6 @@ static bool winbind_name_to_sid_string(struct pwb_context *ctx,
                wbcErr wbc_status;
                struct wbcDomainSid sid;
                enum wbcSidType type;
-               char *sid_str;
 
                _pam_log_debug(ctx, LOG_DEBUG,
                               "no sid given, looking up: %s\n", name);
@@ -1006,15 +1006,16 @@ static bool winbind_name_to_sid_string(struct pwb_context *ctx,
                        return false;
                }
 
-               wbcFreeMemory(sid_str);
                sid_string = sid_str;
        }
 
        if (!safe_append_string(sid_list_buffer, sid_string,
                                sid_list_buffer_size)) {
+               wbcFreeMemory(sid_str);
                return false;
        }
 
+       wbcFreeMemory(sid_str);
        return true;
 }