smpp: fix vlr_subscr use count bugs

In smpp_openbsc.c submit_to_sms(), "get" the appropriate use count upon
assigning sms->receiver, fixing a -1 use count upon sms_free().

Also, avoid a "put" of a NULL subscriber in the same function.

Related: OS#3930
Change-Id: Idaf01cd3cfa08088ce0d543d0576db957dc94262
This commit is contained in:
Neels Hofmeyr 2019-04-15 13:46:44 +02:00
parent e2bd9eb37d
commit 0714002e28
1 changed files with 8 additions and 1 deletions

View File

@ -139,7 +139,8 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net,
} else {
LOGP(DLSMS, LOGL_ERROR,
"SMPP neither message payload nor valid sm_length.\n");
vlr_subscr_put(dest, VSUB_USE_SMPP);
if (dest)
vlr_subscr_put(dest, VSUB_USE_SMPP);
return ESME_RINVPARLEN;
}
}
@ -152,6 +153,12 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net,
/* fill in the destination address */
sms->receiver = dest;
if (dest) {
/* Replace use count from above subscr_by_dst (VSUB_USE_SMPP) by the sms->receiver use count
* (VSUB_USE_SMS_RECEIVER) */
vlr_subscr_get(sms->receiver, VSUB_USE_SMS_RECEIVER);
vlr_subscr_put(dest, VSUB_USE_SMPP);
}
sms->dst.ton = submit->dest_addr_ton;
sms->dst.npi = submit->dest_addr_npi;
if (dest)