diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2020-05-12 17:51:25 +0200 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2020-05-12 17:51:25 +0200 |
commit | dc02c066fd5f1aef282bbbe7efb71094cd08528f (patch) | |
tree | 806170ed0e3fe655e69dc804dd21f63913fed420 /src/logging.c | |
parent | dcad1c55baaa328bb37ea7ec69a3699d8a809a82 (diff) |
logging: do not allow multiple calls of log_init()
calling log_init() multiple times would lead into memory leaks. The
function should only be called once on startup of the process. Lets make
sure that it does not get called multiple times by accident.
Change-Id: Ibb300e4c9b04767581116ab530b2e6a9a195db08
Diffstat (limited to 'src/logging.c')
-rw-r--r-- | src/logging.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/logging.c b/src/logging.c index 4aaf5156..c14e6961 100644 --- a/src/logging.c +++ b/src/logging.c @@ -1028,6 +1028,9 @@ int log_init(const struct log_info *inf, void *ctx) int i; struct log_info_cat *cat_ptr; + /* Ensure that log_init is not called multiple times */ + OSMO_ASSERT(tall_log_ctx == NULL) + tall_log_ctx = talloc_named_const(ctx, 1, "logging"); if (!tall_log_ctx) return -ENOMEM; |