[sr-dev] git:master:feaafdb2: core: test if a module exports functions before converting to core struct

Daniel-Constantin Mierla miconda at gmail.com
Sun Sep 30 21:52:57 CEST 2018


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-09-30T21:52:28+02:00

core: test if a module exports functions before converting to core struct

- reported by Juha Heinanen

---

Modified: src/core/sr_module.c

---

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

---

diff --git a/src/core/sr_module.c b/src/core/sr_module.c
index 6b607ea6ce..199a307068 100644
--- a/src/core/sr_module.c
+++ b/src/core/sr_module.c
@@ -208,7 +208,7 @@ static int register_module(module_exports_t* e, char* path, void* handle)
 	int ret, i;
 	struct sr_module* mod;
 	char defmod[64];
-	int n;
+	int n = 0;
 
 	ret=-1;
 
@@ -227,7 +227,9 @@ static int register_module(module_exports_t* e, char* path, void* handle)
 
 	mod->exports.dlflags = e->dlflags;
 
-	for (n=0; e->cmds[n].name; n++);
+	if(e->cmds) {
+		for (n=0; e->cmds[n].name; n++);
+	}
 	mod->exports.cmds = pkg_malloc(sizeof(ksr_cmd_export_t)*(n+1));
 	memset(mod->exports.cmds, 0, sizeof(ksr_cmd_export_t)*(n+1));
 	for (i=0; i < n; i++) {




More information about the sr-dev mailing list