[sr-dev] git:master:d98d8b65: permissions: safety checks when destroying module

Daniel-Constantin Mierla miconda at gmail.com
Tue Jan 28 08:24:01 CET 2020


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-01-28T08:22:47+01:00

permissions: safety checks when destroying module

- avoid warning of freeing null pointers on failed startup

---

Modified: src/modules/permissions/permissions.c

---

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

---

diff --git a/src/modules/permissions/permissions.c b/src/modules/permissions/permissions.c
index 66caddff6d..f31cadfa23 100644
--- a/src/modules/permissions/permissions.c
+++ b/src/modules/permissions/permissions.c
@@ -48,7 +48,7 @@ MODULE_VERSION
 
 static rule_file_t allow[MAX_RULE_FILES]; /* Parsed allow files */
 static rule_file_t deny[MAX_RULE_FILES];  /* Parsed deny files */
-static int rules_num;  /* Number of parsed allow/deny files */
+static int rules_num = 0;  /* Number of parsed allow/deny files */
 
 
 /* Module parameter variables */
@@ -664,11 +664,11 @@ static void mod_exit(void)
 	int i;
 
 	for(i = 0; i < rules_num; i++) {
-		free_rule(allow[i].rules);
-		pkg_free(allow[i].filename);
+		if(allow[i].rules) free_rule(allow[i].rules);
+		if(allow[i].filename) pkg_free(allow[i].filename);
 
-		free_rule(deny[i].rules);
-		pkg_free(deny[i].filename);
+		if(deny[i].rules) free_rule(deny[i].rules);
+		if(deny[i].filename) pkg_free(deny[i].filename);
 	}
 
 	clean_trusted();




More information about the sr-dev mailing list