Module: kamailio
Branch: 5.3
Commit: aa57ad455b0c0f907bfc5f2f9a0fc382344b7bdb
URL:
https://github.com/kamailio/kamailio/commit/aa57ad455b0c0f907bfc5f2f9a0fc38…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-01-28T08:30:47+01:00
permissions: safety checks when destroying module
- avoid warning of freeing null pointers on failed startup
(cherry picked from commit d98d8b653e5cf0ae358f6abac392ec44ee39548a)
---
Modified: src/modules/permissions/permissions.c
---
Diff:
https://github.com/kamailio/kamailio/commit/aa57ad455b0c0f907bfc5f2f9a0fc38…
Patch:
https://github.com/kamailio/kamailio/commit/aa57ad455b0c0f907bfc5f2f9a0fc38…
---
diff --git a/src/modules/permissions/permissions.c
b/src/modules/permissions/permissions.c
index 2b2e508410..b69cf63922 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 */
@@ -662,11 +662,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();