Browse code

core: clone value for loadmodulex

(cherry picked from commit e04890fe90d6e5ce879f968eb689e8616b318d54)

Daniel-Constantin Mierla authored on 29/06/2021 07:25:30
Showing 1 changed files
... ...
@@ -45,6 +45,7 @@
45 45
 #include "fmsg.h"
46 46
 #include "async_task.h"
47 47
 #include "shm_init.h"
48
+#include "str_list.h"
48 49
 #include "daemonize.h"
49 50
 
50 51
 #include <sys/stat.h>
... ...
@@ -57,6 +58,8 @@
57 58
 
58 59
 
59 60
 struct sr_module* modules=0;
61
+static str_list_t *_ksr_loadmod_strlist = NULL;
62
+
60 63
 
61 64
 /*We need to define this symbol on Solaris becuase libcurl relies on libnspr which looks for this symbol.
62 65
   If it is not defined, dynamic module loading (dlsym) fails */
... ...
@@ -656,6 +659,7 @@ int load_modulex(char* mod_path)
656 659
 	str sfmt;
657 660
 	sip_msg_t *fmsg;
658 661
 	char* emod;
662
+	str_list_t *sb;
659 663
 
660 664
 	emod = mod_path;
661 665
 	if(strchr(mod_path, '$') != NULL) {
... ...
@@ -663,7 +667,12 @@ int load_modulex(char* mod_path)
663 667
 		sfmt.s = mod_path;
664 668
 		sfmt.len = strlen(sfmt.s);
665 669
 		if(pv_eval_str(fmsg, &seval, &sfmt)>=0) {
666
-			emod = seval.s;
670
+			sb = str_list_block_add(&_ksr_loadmod_strlist, seval.s, seval.len);
671
+			if(sb==NULL) {
672
+				LM_ERR("failed to handle load module: %s\n", mod_path);
673
+				return -1;
674
+			}
675
+			emod = sb->s.s;
667 676
 		}
668 677
 	}
669 678