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
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index 01c39f9..151c788 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -139,7 +139,8 @@
 		} 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 @@
 
 	/* 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)