aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmsc')
-rw-r--r--src/libmsc/smpp_smsc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libmsc/smpp_smsc.c b/src/libmsc/smpp_smsc.c
index 7bbb0a4e7..ea5303c0d 100644
--- a/src/libmsc/smpp_smsc.c
+++ b/src/libmsc/smpp_smsc.c
@@ -977,6 +977,12 @@ struct smsc *smpp_smsc_alloc_init(void *ctx)
/*! \brief Set the SMPP address and port without binding. */
int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port)
{
+ smsc->listen_port = port;
+
+ /* Avoid use-after-free if bind_addr == smsc->bind_addr */
+ if (smsc->bind_addr == bind_addr)
+ return 0;
+
talloc_free((void*)smsc->bind_addr);
smsc->bind_addr = NULL;
if (bind_addr) {
@@ -984,7 +990,6 @@ int smpp_smsc_conf(struct smsc *smsc, const char *bind_addr, uint16_t port)
if (!smsc->bind_addr)
return -ENOMEM;
}
- smsc->listen_port = port;
return 0;
}