[PATCH 7/7] CLI: add simple error handling for talloc logging

Subject: [PATCH 7/7] CLI: add simple error handling for talloc logging

Date: Sat, 19 Jan 2013 14:25:58 -0400

To: notmuch@notmuchmail.org

Cc: David Bremner

From: david@tethera.net


From: David Bremner <bremner@debian.org>

This really should have been there before. I think it's better to do
the actual operation and then possibly fail writing the memory log,
but it would not be too hard to change it to abort earlier.
---
 notmuch.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/notmuch.c b/notmuch.c
index f8d4b35..c3336e8 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -301,7 +301,12 @@ main (int argc, char *argv[])
 
 	    if (leak_report && (strcmp (leak_report, "") != 0)) {
 		FILE *report = fopen (leak_report, "w");
-		talloc_report_full (NULL, report);
+		if (report) {
+		    talloc_report_full (NULL, report);
+		} else {
+		    ret = 1;
+		    perror (leak_report);
+		}
 	    }
 
 	    return ret;
-- 
1.7.10.4


Thread: