svn commit: samba r20908 - in branches/SAMBA_4_0/source/scripting/ejs/ejsnet: .

metze at samba.org metze at samba.org
Fri Jan 19 15:37:20 GMT 2007


Author: metze
Date: 2007-01-19 15:37:20 +0000 (Fri, 19 Jan 2007)
New Revision: 20908

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20908

Log:
- fix uninitialized usage of 'ctx'
- remove unused mem_ctx variable
- copy the userman_domain string as child of obj

metze
Modified:
   branches/SAMBA_4_0/source/scripting/ejs/ejsnet/net_user.c


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/ejsnet/net_user.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/ejsnet/net_user.c	2007-01-19 15:33:11 UTC (rev 20907)
+++ branches/SAMBA_4_0/source/scripting/ejs/ejsnet/net_user.c	2007-01-19 15:37:20 UTC (rev 20908)
@@ -41,11 +41,17 @@
 */
 int ejs_net_userman(MprVarHandle eid, int argc, struct MprVar **argv)
 {
-	TALLOC_CTX *mem_ctx;
 	struct libnet_context *ctx;
 	const char *userman_domain = NULL;
 	struct MprVar *obj = NULL;
 
+	/* libnet context */
+	ctx = mprGetThisPtr(eid, "ctx");
+	if (ctx == NULL) {
+		ejsSetErrorMsg(eid, "ctx property returns null pointer");
+		return 0;
+	}
+
 	/* fetch the arguments: domain name */
 	if (argc == 0) {
 		/* default domain name is supplied in credentials */
@@ -54,31 +60,25 @@
 	} else if (argc == 1 && mprVarIsString(argv[0]->type)) {
 		/* domain name can also be specified explicitly 
 		   (e.g. to connect remote domain) */
-		userman_domain = talloc_strdup(ctx, mprToString(argv[0]));
+		userman_domain = mprToString(argv[0]);
 
 	} else {
 		ejsSetErrorMsg(eid, "too many arguments");
-		goto done;
+		return 0;
 	}
 
-	/* libnet context */
-	ctx = mprGetThisPtr(eid, "ctx");
-	if (ctx == NULL) {
-		ejsSetErrorMsg(eid, "ctx property returns null pointer");
-		goto done;
-	}
-	
-	mem_ctx = talloc_new(mprMemCtx());
-
 	/* any domain name must be specified anyway */
 	if (userman_domain == NULL) {
 		ejsSetErrorMsg(eid, "a domain must be specified for user management");
-		goto done;
+		return 0;
 	}
-	
+
 	/* create 'net user' subcontext */
 	obj = mprInitObject(eid, "NetUsrCtx", argc, argv);
 
+	/* we need to make a copy of the string for this object */
+	userman_domain = talloc_strdup(obj, userman_domain);
+
 	/* add properties */
 	mprSetPtrChild(obj, "ctx", ctx);
 	mprSetPtrChild(obj, "domain", userman_domain);
@@ -89,8 +89,6 @@
 	mprSetStringCFunction(obj, "Info", ejs_net_userinfo);
 	mprSetCFunction(obj, "List", ejs_net_userlist);
 
-done:
-	talloc_free(mem_ctx);
 	return 0;
 }
 



More information about the samba-cvs mailing list