aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-09-19 04:34:04 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-09-20 02:48:43 +0800
commit3c7921472767d9818417f7a8b70730684c82bc00 (patch)
tree456ff196f6dc7a49f324085e4c7bcd9c5680b648 /openbsc/src
parente3946f458a9c585c194a88f8260cb61ffd89b443 (diff)
nat: NULL check the allocation and print a nice warning.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index 1728a41e7..db0fb743b 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -660,6 +660,12 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat)
nat->bsc_endpoints = talloc_zero_array(nat,
struct bsc_endpoint,
nat->mgcp_cfg->number_endpoints + 1);
+ if (!nat->bsc_endpoints) {
+ LOGP(DMGCP, LOGL_ERROR, "Failed to allocate nat endpoints\n");
+ close(nat->mgcp_queue.bfd.fd);
+ nat->mgcp_queue.bfd.fd = -1;
+ return -1;
+ }
return 0;
}