]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libnet dssync: start memory allocation cleanup: use tmp ctx in libnet_dssync().
authorMichael Adam <obnox@samba.org>
Fri, 1 Aug 2008 15:13:42 +0000 (17:13 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 1 Aug 2008 15:13:42 +0000 (17:13 +0200)
Don't leak temporary data to callers but use a temporary context
that is freed at the end.

Michael

source/libnet/libnet_dssync.c

index 3641505d991a7c3aaf6bd2de9f392da40e2aec2d..684a2cc63bfd22a95c263fd8232130d6adc123e2 100644 (file)
@@ -696,18 +696,25 @@ NTSTATUS libnet_dssync(TALLOC_CTX *mem_ctx,
                       struct dssync_context *ctx)
 {
        NTSTATUS status;
+       TALLOC_CTX *tmp_ctx;
 
-       status = libnet_dssync_init(mem_ctx, ctx);
+       tmp_ctx = talloc_new(mem_ctx);
+       if (!tmp_ctx) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       status = libnet_dssync_init(tmp_ctx, ctx);
        if (!NT_STATUS_IS_OK(status)) {
                goto out;
        }
 
-       status = libnet_dssync_process(mem_ctx, ctx);
+       status = libnet_dssync_process(tmp_ctx, ctx);
        if (!NT_STATUS_IS_OK(status)) {
                goto out;
        }
 
  out:
+       TALLOC_FREE(tmp_ctx);
        return status;
 }