From 9981430898f2b6f0eb8cf6e61b893faba85e2553 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 10 Mar 2013 20:30:11 +0100 Subject: [PATCH] utils error: Make sure to destroy memory allocated for error information. --- src/utils/error.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/error.c b/src/utils/error.c index 34213b3..08a77f1 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -33,6 +33,8 @@ #include #include +#include + /* * private data types */ @@ -57,13 +59,21 @@ static _Bool error_ctx_key_initialized = 0; * private helper functions */ +static void +sdb_error_ctx_destructor(void *ctx) +{ + if (! ctx) + return; + free(ctx); +} /* sdb_error_ctx_destructor */ + static void sdb_error_ctx_init(void) { if (error_ctx_key_initialized) return; - pthread_key_create(&error_ctx_key, NULL); + pthread_key_create(&error_ctx_key, sdb_error_ctx_destructor); error_ctx_key_initialized = 1; } /* sdb_error_init */ -- 2.30.2