[sr-dev] git:master:e5134e8c: call_obj: free current element in case of alloc failure to its field

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 30 14:16:58 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-06-30T13:46:21+02:00

call_obj: free current element in case of alloc failure to its field

---

Modified: src/modules/call_obj/cobj.c

---

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

---

diff --git a/src/modules/call_obj/cobj.c b/src/modules/call_obj/cobj.c
index 3a6ba31e51..cf014b659f 100644
--- a/src/modules/call_obj/cobj.c
+++ b/src/modules/call_obj/cobj.c
@@ -436,6 +436,8 @@ int cobj_get_timestamp(uint64_t ts, cobj_elem_t **elem, int limit)
 			elem_new->callid.s = (char*)pkg_malloc(obj->callid.len + 1); /* +1 Zero at the end */
 			if (!elem_new->callid.s) {
 				LM_ERR("Cannot allocate memory for callid\n");
+				pkg_free(elem_new);
+				elem_new = NULL;
 				goto clean;
 			}
 			memcpy(elem_new->callid.s, obj->callid.s, obj->callid.len);




More information about the sr-dev mailing list