PREVIEW: Steal ldb_msg in ldb_context so it doesn't appear as a memory leak ldb-mem-fix-2
authorKamen Mazdrashki <kamenim@samba.org>
Sun, 4 Jul 2010 19:34:21 +0000 (22:34 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Sun, 4 Jul 2010 19:36:33 +0000 (22:36 +0300)
In case of this ldbadd utility, it is safe to allocate memory
in ldb_context context, as it is not intended to work 24/7,
so ldb_context will be freed quickly.

source4/lib/ldb/tools/ldbadd.c

index e057b873a8c34d5f50ba75428b542ea0cd93aabe..7222c16b10a7a294b4ca2ce65195582fc939f85e 100644 (file)
@@ -69,6 +69,11 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
                }
 
                ldif->msg = ldb_msg_canonicalize(ldb, ldif->msg);
+               if (ldif->msg == NULL) {
+                       fprintf(stderr, "Not enough memory!\n");
+                       return -1;
+               }
+               talloc_steal(ldb, ldif->msg);
 
                ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls);
                if (ret != LDB_SUCCESS) {