summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index ec2748a426..83d5f1ae44 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -129,7 +129,7 @@ static int ejs_ldbAddModify(MprVarHandle eid, int argc, struct MprVar **argv,
const char *ldifstring;
struct ldb_context *ldb;
struct ldb_ldif *ldif;
- int ret = 0;
+ int ret = 0, count=0;
if (argc != 1) {
ejsSetErrorMsg(eid, "ldb.add/modify invalid arguments");
@@ -148,11 +148,17 @@ static int ejs_ldbAddModify(MprVarHandle eid, int argc, struct MprVar **argv,
}
while ((ldif = ldb_ldif_read_string(ldb, &ldifstring))) {
+ count++;
ret = fn(ldb, ldif->msg);
talloc_free(ldif);
if (ret != 0) break;
}
+ if (count == 0) {
+ ejsSetErrorMsg(eid, "ldb.add/modify invalid ldif");
+ return -1;
+ }
+
mpr_Return(eid, mprCreateBoolVar(ret == 0));
return 0;
}
@@ -384,8 +390,6 @@ static int ejs_ldbClose(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- talloc_free(ldb);
-
mprSetThisPtr(eid, "db", NULL);
mpr_Return(eid, mprCreateBoolVar(True));
return 0;