From 78338d431c6e4ae8e3ff94b0ba9caaae2a5626a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Sep 2009 16:42:11 -0700 Subject: talloc: don't crash if f is NULL in talloc_report_* It's annoying when you use p talloc_report_full(ctx, fopen("/tmp/xx","w")) in gdb, and if you don't have write permission on the file then you get a segv. --- lib/talloc/talloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/talloc/talloc.c') diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 478767c955..f103a9b941 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -1421,8 +1421,10 @@ static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_ */ void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f) { - talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f); - fflush(f); + if (f) { + talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f); + fflush(f); + } } /* -- cgit