diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-12-28 14:04:36 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-03 16:19:07 +0100 |
commit | 5331cf8dbdae6b29df50556c362462b973e93917 (patch) | |
tree | fa46cbaef836cdbf616efe69e971cd334614bfb6 /openbsc/src/libcommon | |
parent | cf8e56cd1e057a39a5acdc6f78b9a69bb1b4c281 (diff) |
subscr_name(): Handle case for subscr == NULL
subscr_name() was called from several places:
* either without a check for subscr being NULL, which for example
was causing a segfault if we hand-over a channel before identifying the
subscriber
* or with an explicit NULL check and the ternary operator (?).
We now simplify the code by checking for the NULL Subscriber in subscr_name()
itself.
Diffstat (limited to 'openbsc/src/libcommon')
-rw-r--r-- | openbsc/src/libcommon/gsm_subscriber_base.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/openbsc/src/libcommon/gsm_subscriber_base.c b/openbsc/src/libcommon/gsm_subscriber_base.c index a455824a3..2bf8c098c 100644 --- a/openbsc/src/libcommon/gsm_subscriber_base.c +++ b/openbsc/src/libcommon/gsm_subscriber_base.c @@ -43,6 +43,9 @@ struct llist_head *subscr_bsc_active_subscribers(void) char *subscr_name(struct gsm_subscriber *subscr) { + if (!subscr) + return "unknown"; + if (strlen(subscr->name)) return subscr->name; |