summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2019-11-18 13:46:53 +1300
committerAndrew Bartlett <abartlet@samba.org>2019-11-20 04:41:27 +0000
commitc90bc75df8446c79a9e251c7b07a59674d828505 (patch)
tree3db5b3d49d7d316d73d47d37426b62747598e262 /librpc
parent8a6f1de67b1c2e925cce8fb20b6657a425cbaedb (diff)
downloadsamba-c90bc75df8446c79a9e251c7b07a59674d828505.tar.gz
ndrdump: TALLOC_FREE() on each exit path to allow running with leak detection
This allows us to learn if there are other memory leaks not on the mem_ctx during the processing of the packet. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/tools/ndrdump.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c
index f507db0011c..9465a7c4fa5 100644
--- a/librpc/tools/ndrdump.c
+++ b/librpc/tools/ndrdump.c
@@ -422,6 +422,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
printf("Unable to allocate %d bytes for %s structure\n",
(int)f->struct_size,
f->name);
+ TALLOC_FREE(mem_ctx);
exit(1);
}
@@ -431,18 +432,21 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
"structure\n",
(int)f->struct_size,
f->name);
+ TALLOC_FREE(mem_ctx);
exit(1);
}
if (ctx_filename) {
if (flags & NDR_IN) {
printf("Context file can only be used for \"out\" packages\n");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
data = (uint8_t *)file_load(ctx_filename, &size, 0, mem_ctx);
if (!data) {
perror(ctx_filename);
+ TALLOC_FREE(mem_ctx);
exit(1);
}
@@ -452,6 +456,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
if (ndr_pull == NULL) {
perror("ndr_pull_init_blob");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
@@ -474,6 +479,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
printf("pull for context file returned %s\n",
ndr_map_error2string(ndr_err));
+ TALLOC_FREE(mem_ctx);
exit(1);
}
memcpy(v_st, st, f->struct_size);
@@ -502,6 +508,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
if (ndr_pull == NULL) {
perror("ndr_pull_init_blob");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
@@ -542,6 +549,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
&f->out_pipes);
if (!NT_STATUS_IS_OK(status)) {
printf("dump FAILED\n");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
}
@@ -552,6 +560,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
if (stop_on_parse_failure && !NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
printf("not printing because --stop-on-parse-failure\n");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
@@ -611,6 +620,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
ndr_map_error2string(ndr_err));
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
printf("validate push FAILED\n");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
@@ -624,6 +634,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx);
if (ndr_v_pull == NULL) {
perror("ndr_pull_init_blob");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
@@ -633,6 +644,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
ndr_map_error2string(ndr_err));
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
printf("validate pull FAILED\n");
+ TALLOC_FREE(mem_ctx);
exit(1);
}
@@ -694,7 +706,7 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...)
}
printf("dump OK\n");
- talloc_free(mem_ctx);
+ TALLOC_FREE(mem_ctx);
poptFreeContext(pc);