From 7a0af9ae18cda6d4f0d735abd0f903eebc8a206a Mon Sep 17 00:00:00 2001 From: Love Hornquist Astrand Date: Mon, 21 Sep 2009 06:21:23 -0700 Subject: [PATCH] Its ok to pass down NULL as the context handle to error string function Just ignore setting the error string if that is the case. --- lib/hx509/error.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/hx509/error.c b/lib/hx509/error.c index 45813efb3..fc3cf90b3 100644 --- a/lib/hx509/error.c +++ b/lib/hx509/error.c @@ -67,8 +67,10 @@ free_error_string(hx509_error msg) void hx509_clear_error_string(hx509_context context) { - free_error_string(context->error); - context->error = NULL; + if (context) { + free_error_string(context->error); + context->error = NULL; + } } /** @@ -91,6 +93,9 @@ hx509_set_error_stringv(hx509_context context, int flags, int code, { hx509_error msg; + if (context == NULL) + return; + msg = calloc(1, sizeof(*msg)); if (msg == NULL) { hx509_clear_error_string(context);