diff options
author | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-15 23:28:33 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-15 23:28:33 +0100 |
commit | 2037bc64f587006520a385d06904c2710ab9a8ba (patch) | |
tree | c0ea5c6759b2a661040c258b1b29b2993cd675d9 /src | |
parent | d453a4c2a4413d8aeafea70b2389194a7e5e24b0 (diff) |
free a mem leak by statically allocating global statsbuf
Diffstat (limited to 'src')
-rw-r--r-- | src/stats.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/stats.c b/src/stats.c index 9f4acc3..dfe054c 100644 --- a/src/stats.c +++ b/src/stats.c @@ -43,7 +43,7 @@ struct stat_s { unsigned long int num_denied; }; -static struct stat_s *stats; +static struct stat_s stats_buf, *stats; static pthread_mutex_t stats_update_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t stats_file_lock = PTHREAD_MUTEX_INITIALIZER; @@ -52,11 +52,7 @@ static pthread_mutex_t stats_file_lock = PTHREAD_MUTEX_INITIALIZER; */ void init_stats (void) { - stats = (struct stat_s *) safemalloc (sizeof (struct stat_s)); - if (!stats) - return; - - memset (stats, 0, sizeof (struct stat_s)); + stats = &stats_buf; } /* |