From ed4a3e53fd71679fbdfc2f2932c1098e03026285 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 20:38:10 +0000 Subject: [PATCH] r12856: make the logic much more sane metze --- source/librpc/ndr/ndr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/librpc/ndr/ndr.c b/source/librpc/ndr/ndr.c index 9e307a3f38b..a7f34ec0020 100644 --- a/source/librpc/ndr/ndr.c +++ b/source/librpc/ndr/ndr.c @@ -272,16 +272,20 @@ char *ndr_print_function_string(TALLOC_CTX *mem_ctx, int flags, void *ptr) { struct ndr_print *ndr; - char *ret; + char *ret = NULL; ndr = talloc_zero(mem_ctx, struct ndr_print); if (!ndr) return NULL; - ndr->private = talloc_strdup(mem_ctx, ""); + ndr->private = talloc_strdup(ndr, ""); + if (!ndr->private) { + goto failed; + } ndr->print = ndr_print_string_helper; ndr->depth = 1; ndr->flags = 0; fn(ndr, name, flags, ptr); - ret = ndr->private; + ret = talloc_steal(mem_ctx, ndr->private); +failed: talloc_free(ndr); return ret; }