[sr-dev] git:master:0db313f0: tmx: check for empty result not to allocate 0 bytes

Daniel-Constantin Mierla miconda at gmail.com
Thu May 14 13:53:03 CEST 2015


Module: kamailio
Branch: master
Commit: 0db313f0047fc512dec2976cac168989b60d49c8
URL: https://github.com/kamailio/kamailio/commit/0db313f0047fc512dec2976cac168989b60d49c8

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-05-14T13:24:38+02:00

tmx: check for empty result not to allocate 0 bytes

- allocation of 0 size is undefined when using system malloc

---

Modified: modules/tmx/t_mi.c

---

Diff:  https://github.com/kamailio/kamailio/commit/0db313f0047fc512dec2976cac168989b60d49c8.diff
Patch: https://github.com/kamailio/kamailio/commit/0db313f0047fc512dec2976cac168989b60d49c8.patch

---

diff --git a/modules/tmx/t_mi.c b/modules/tmx/t_mi.c
index 735e911..485b160 100644
--- a/modules/tmx/t_mi.c
+++ b/modules/tmx/t_mi.c
@@ -228,6 +228,10 @@ static inline char *get_hfblock( str *uri, struct hdr_field *hf, int *l, struct
 		LM_DBG("one more hf processed\n");
 	} /* header loop */
 
+	if(total_len==0) {
+		LM_DBG("empty result\n");
+		goto error;
+	}
 
 	/* construct a single header block now */
 	ret=pkg_malloc(total_len);




More information about the sr-dev mailing list