This patch fixes...

"Rene Kluwen" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
.a memory leak in opensmppbox whilst using v3.4 tlv values in incoming
messages.

 

Rather than using this patch, I don't want to allocate a dict in
smpp_pdu_create at all. But I am not sure about how it will affect the rest
of the smpp code.

 

== Rene
tlv_memory_leak.diff (application/octet-stream, 1.7 KB)
Index: gw/opensmppbox.c
===================================================================
--- gw/opensmppbox.c	(revision 62)
+++ gw/opensmppbox.c	(working copy)
@@ -901,6 +901,9 @@
 			if (box->version > 0x33) {
 				pdu2->u.deliver_sm.receipted_message_id = octstr_duplicate(msgid2);
 				pdu2->u.deliver_sm.message_state = dlr_state;
+				if (pdu2->u.deliver_sm.tlv) {
+				    dict_destroy(pdu2->u.deliver_sm.tlv);
+				}
 				pdu2->u.deliver_sm.tlv = meta_data_get_values(msg->sms.meta_data, "smpp");
 			}
 			pdu2->u.deliver_sm.short_message = octstr_format("id:%S sub:001 dlvrd:%S submit date:%s done date:%s stat:%S err:%s text:%12s", msgid2, dlvrd, submit_date_c_str, done_date_c_str, dlr_status, err, text);
@@ -913,6 +916,9 @@
 		if (box->version > 0x33) {
 			pdu->u.deliver_sm.receipted_message_id = octstr_duplicate(msgid);
 			pdu->u.deliver_sm.message_state = dlr_state;
+			if (pdu->u.deliver_sm.tlv) {
+			    dict_destroy(pdu->u.deliver_sm.tlv);
+			}
 			pdu->u.deliver_sm.tlv = meta_data_get_values(msg->sms.meta_data, "smpp");
 		}
 		pdu->u.deliver_sm.short_message = octstr_format("id:%S sub:001 dlvrd:%S submit date:%s done date:%s stat:%S err:%s text:%12s", msgid, dlvrd, submit_date_c_str, done_date_c_str, dlr_status, err, text);
@@ -1053,6 +1059,9 @@
 	        }
 
 	        if (box->version > 0x33) {
+		    if (pdu2->u.deliver_sm.tlv) {
+			dict_destroy(pdu2->u.deliver_sm.tlv);
+		    }
 	            pdu2->u.deliver_sm.tlv = meta_data_get_values(msg->sms.meta_data, "smpp");
 	        }
 
@@ -1064,6 +1073,9 @@
     }
     else {
         if (box->version > 0x33) {
+	    if (pdu->u.deliver_sm.tlv) {
+		dict_destroy(pdu->u.deliver_sm.tlv);
+	    }
             pdu->u.deliver_sm.tlv = meta_data_get_values(msg->sms.meta_data, "smpp");
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.