diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-12-28 14:04:36 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-22 11:51:18 +0000 |
commit | 7184bd088e11cfe6b907af2fcce48369fd2f21f1 (patch) | |
tree | a27d5594ce7539577eb4f652f2f6d44867d7e113 /openbsc/src/libcommon/gsm_subscriber_base.c | |
parent | 8495e03588f0b880be6f053c81b87fa4eca025d7 (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.
Change-Id: Ide09f4a515222eb2ec6c25e7a6a8c5f6cc2ffd4b
Reviewed-on: https://gerrit.osmocom.org/92
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
Diffstat (limited to 'openbsc/src/libcommon/gsm_subscriber_base.c')
-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 50f411888..1f98cc66c 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; |