diff options
Diffstat (limited to 'openbsc/src/osmo-bsc_nat/bsc_nat_utils.c')
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index f83289b61..4258364fe 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -606,8 +606,11 @@ int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg, } } -void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) +int bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) { + int ret; + + ret = 0; if (*imsi) { talloc_free(*imsi); *imsi = NULL; @@ -616,8 +619,16 @@ void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char ** if (argc > 0) { *imsi = talloc_strdup(ctx, argv[0]); - regcomp(reg, argv[0], 0); + ret = regcomp(reg, argv[0], 0); + + /* handle compilation failures */ + if (ret != 0) { + talloc_free(*imsi); + *imsi = NULL; + } } + + return ret; } static const char *con_types [] = { |