s4-ldb: use a parent context in the ldb utils
authorAndrew Tridgell <tridge@samba.org>
Sun, 2 May 2010 13:53:14 +0000 (15:53 +0200)
committerAndrew Tridgell <tridge@samba.org>
Sun, 2 May 2010 16:25:13 +0000 (18:25 +0200)
This avoids a talloc free with references error on exit

source4/lib/ldb/tools/ldbadd.c
source4/lib/ldb/tools/ldbdel.c
source4/lib/ldb/tools/ldbedit.c
source4/lib/ldb/tools/ldbmodify.c
source4/lib/ldb/tools/ldbrename.c
source4/lib/ldb/tools/ldbsearch.c

index 0dd35cc1b3c815d052262cdb9f140e1ce33b950f..e057b873a8c34d5f50ba75428b542ea0cd93aabe 100644 (file)
@@ -95,8 +95,9 @@ int main(int argc, const char **argv)
        struct ldb_context *ldb;
        unsigned int i, count = 0;
        int ret=0;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -130,7 +131,7 @@ int main(int argc, const char **argv)
                ldb_transaction_cancel(ldb);
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
 
        printf("Added %d records with %d failures\n", count, failures);
        
index 04884e1becb6df87f5db2389b2e28178a9e6c2b5..6994b3ddb681051835a3b290c8801566af50835a 100644 (file)
@@ -87,8 +87,9 @@ int main(int argc, const char **argv)
        struct ldb_cmdline *options;
        struct ldb_context *ldb;
        int ret = 0, i;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -127,7 +128,7 @@ int main(int argc, const char **argv)
                }
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
 
        return ret;
 }
index 4c5683cd835f9c8c615ec3acb7faa3c5f05e7de0..1866cc373e3d88c39cf4544dd0d95beb3d893d11 100644 (file)
@@ -284,8 +284,9 @@ int main(int argc, const char **argv)
        int ret;
        const char *expression = "(|(objectClass=*)(distinguishedName=*))";
        const char * const * attrs = NULL;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -330,6 +331,7 @@ int main(int argc, const char **argv)
                }
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
+
        return 0;
 }
index 57988cbb308e8ed99e1124af34e1545e9b3a828c..ecbdadfd65446bdb776d4990766076538a0c01ae 100644 (file)
@@ -94,8 +94,9 @@ int main(int argc, const char **argv)
        struct ldb_context *ldb;
        int count=0;
        int i, ret=LDB_SUCCESS;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -115,7 +116,7 @@ int main(int argc, const char **argv)
                }
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
 
        printf("Modified %d records with %d failures\n", count, failures);
 
index bfccacc2066d70214bd68c7ef64538180b731abd..e0f258ce858b4dde7466dfe07fc04322889e7a5c 100644 (file)
@@ -51,8 +51,9 @@ int main(int argc, const char **argv)
        int ret;
        struct ldb_cmdline *options;
        struct ldb_dn *dn1, *dn2;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -71,7 +72,7 @@ int main(int argc, const char **argv)
                        options->argv[0], options->argv[1], ldb_errstring(ldb));
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
        
        return ret;
 }
index 327a75ed8d3221310a55a8b27daac3509764d421..179646c73fbe3b8999ac6ebfeafaccca0a6b1e9c 100644 (file)
@@ -271,8 +271,9 @@ int main(int argc, const char **argv)
        struct ldb_cmdline *options;
        int ret = -1;
        const char *expression = "(|(objectClass=*)(distinguishedName=*))";
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
-       ldb = ldb_init(NULL, NULL);
+       ldb = ldb_init(mem_ctx, NULL);
        if (ldb == NULL) {
                return -1;
        }
@@ -311,6 +312,7 @@ int main(int argc, const char **argv)
                ret = do_search(ldb, basedn, options, expression, attrs);
        }
 
-       talloc_free(ldb);
+       talloc_free(mem_ctx);
+
        return ret;
 }