[sr-dev] git:master:3afd4acf: db_text: free pkg memory before return on error

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 28 10:39:29 CEST 2017


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

Author: Mikko Lehto <mslehto at iki.fi>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-28T10:39:23+02:00

db_text: free pkg memory before return on error

---

Modified: src/modules/db_text/dbt_raw_util.c

---

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

---

diff --git a/src/modules/db_text/dbt_raw_util.c b/src/modules/db_text/dbt_raw_util.c
index 89fcc803a4..92b60287d6 100644
--- a/src/modules/db_text/dbt_raw_util.c
+++ b/src/modules/db_text/dbt_raw_util.c
@@ -206,8 +206,12 @@ int dbt_build_where(char* where, db_key_t** _k, db_op_t** _o, db_val_t** _v)
 	memset(_v1, 0, sizeof(db_val_t) * MAX_CLAUSES);
 
 	matches = (regmatch_t*)pkg_malloc(sizeof(regmatch_t) * MAX_MATCH);
-	if(matches==NULL) {
+	if(matches==NULL || _k1==NULL || _o1==NULL || _v1==NULL) {
 		LM_ERR("error getting pkg memory\n");
+		pkg_free(_k1);
+		pkg_free(_o1);
+		pkg_free(_v1);
+		pkg_free(matches);
 		return -1;
 	}
 




More information about the sr-dev mailing list