Browse Source

core: modparam - safety check for str s pointer

- deal with the case of argument with 'nonnull' attribute passed null
Daniel-Constantin Mierla 3 years ago
parent
commit
69c004eec1
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/core/modparam.c

+ 6 - 0
src/core/modparam.c

@@ -147,6 +147,12 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
 							break;
 
 						case PARAM_STR:
+							if( ((str*)val2)->s==NULL) {
+								LM_ERR("null value\n");
+								regfree(&preg);
+								pkg_free(reg);
+								return -1;
+							}
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
 							if (!((str*)ptr)->s) {
 								PKG_MEM_ERROR;