From af891a04d3bcb595d724c541b7acd1efa9b2aae5 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Tue, 20 Nov 2012 14:53:18 +0000 Subject: [PATCH] Changed the SQLite3 error handling due to possible SegFault and invalid pointer messages in Apache. --- apache/mod_blockinator.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apache/mod_blockinator.c b/apache/mod_blockinator.c index dbd2daf..9b9bfda 100644 --- a/apache/mod_blockinator.c +++ b/apache/mod_blockinator.c @@ -57,7 +57,6 @@ static int mod_blockinator_method_handler(request_rec *r) { const char *remote_ip, *forwarded_ip, *useragent; char *statement; - char *sqlite3_error; sqlite3_stmt *sqlite3_statement; int sqlite3_rc; @@ -94,10 +93,10 @@ static int mod_blockinator_method_handler(request_rec *r) /* Tidy-up the SQLite way. */ if (sqlite3_finalize(sqlite3_statement) != SQLITE_OK) { - ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "SQLite error freeing the SQLite compile statement (%s). Possible memory leak.", sqlite3_error); - sqlite3_free(sqlite3_error); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "SQLite error freeing the SQLite compile statement (%s). Possible memory leak.", sqlite3_errmsg(db)); } + sqlite3_free(statement); return DECLINED; } @@ -106,8 +105,6 @@ static int mod_blockinator_method_handler(request_rec *r) */ static void mod_blockinator_init_handler(apr_pool_t *p, server_rec *s) { - char *sqlite3_error; - /* Read config from module */ blockinator_cfg_t *cfg = ap_get_module_config(s->module_config, &blockinator_module);