From: Sebastian Harl Date: Sun, 10 Mar 2013 19:30:11 +0000 (+0100) Subject: utils error: Make sure to destroy memory allocated for error information. X-Git-Tag: sysdb-0.1.0~434 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9981430898f2b6f0eb8cf6e61b893faba85e2553;p=sysdb.git utils error: Make sure to destroy memory allocated for error information. --- 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 */