r9755: Fix crash bug in SWAT login
authorJelmer Vernooij <jelmer@samba.org>
Mon, 29 Aug 2005 19:08:18 +0000 (19:08 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:56 +0000 (13:34 -0500)
source/scripting/ejs/smbcalls_auth.c

index 8df69cf087318a882a536019b42d439cba4733c9..e3b48490f6c8d41468c293ff475ec02a88972e28 100644 (file)
@@ -119,6 +119,9 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
                ejsSetErrorMsg(eid, "userAuth requires a 'creds' element");
                return -1;
        }
                ejsSetErrorMsg(eid, "userAuth requires a 'creds' element");
                return -1;
        }
+
+       tmp_ctx = talloc_new(mprMemCtx());      
+       
        username    = cli_credentials_get_username(creds, tmp_ctx);
        password    = cli_credentials_get_password(creds);
        domain      = cli_credentials_get_domain(creds);
        username    = cli_credentials_get_username(creds, tmp_ctx);
        password    = cli_credentials_get_password(creds);
        domain      = cli_credentials_get_domain(creds);
@@ -126,10 +129,10 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
 
        if (username == NULL || password == NULL || domain == NULL) {
                mpr_Return(eid, mprCreateUndefinedVar());
 
        if (username == NULL || password == NULL || domain == NULL) {
                mpr_Return(eid, mprCreateUndefinedVar());
+               talloc_free(tmp_ctx);
                return 0;
        }
 
                return 0;
        }
 
-       tmp_ctx = talloc_new(mprMemCtx());      
        auth = mprObject("auth");
 
        if (domain && strcmp("System User", domain) == 0) {
        auth = mprObject("auth");
 
        if (domain && strcmp("System User", domain) == 0) {