[sr-dev] git:master:2a80448b: xprint: use pkg_reallocxf() to ensure old pointer is freed in case of failure

Daniel-Constantin Mierla miconda at gmail.com
Thu Aug 10 11:20:15 CEST 2017


Module: kamailio
Branch: master
Commit: 2a80448b07b39dece0770bd04014a12e2d0390d8
URL: https://github.com/kamailio/kamailio/commit/2a80448b07b39dece0770bd04014a12e2d0390d8

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-10T10:55:07+02:00

xprint: use pkg_reallocxf() to ensure old pointer is freed in case of failure

- fix also potential free of null

---

Modified: src/modules/xprint/xp_lib.c

---

Diff:  https://github.com/kamailio/kamailio/commit/2a80448b07b39dece0770bd04014a12e2d0390d8.diff
Patch: https://github.com/kamailio/kamailio/commit/2a80448b07b39dece0770bd04014a12e2d0390d8.patch

---

diff --git a/src/modules/xprint/xp_lib.c b/src/modules/xprint/xp_lib.c
index d68bd64c05..068608a304 100644
--- a/src/modules/xprint/xp_lib.c
+++ b/src/modules/xprint/xp_lib.c
@@ -1862,9 +1862,8 @@ int xl_mod_init()
 		str_domainname.s = NULL;
 	} else {
 		str_fullname.len = strlen(s);
-		s = pkg_realloc(s, str_fullname.len+1); /* this will leave the ending \0 */
+		s = pkg_reallocxf(s, str_fullname.len+1); /* this will leave the ending \0 */
 		if (!s) { /* should never happen because decreasing size */
-			pkg_free(s);
 			return -1;
 		}
 		str_fullname.s = s;




More information about the sr-dev mailing list