smpp_smsc.c: don't talloc_strdup NULL pointers

This commit is contained in:
the 34c3 gsm team 2017-12-28 15:38:05 +01:00
parent 02dd4425a0
commit 63045a2069
1 changed files with 3 additions and 1 deletions

View File

@ -971,10 +971,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)
{
const char *tmpaddr = bind_addr ? talloc_strdup(smsc, bind_addr) : NULL;
talloc_free((void*)smsc->bind_addr);
smsc->bind_addr = NULL;
if (bind_addr) {
smsc->bind_addr = talloc_strdup(smsc, bind_addr);
smsc->bind_addr = tmpaddr;
if (!smsc->bind_addr)
return -ENOMEM;
}