Browse code

core: free allocated memory in case of failing to get more for modparams

- keep shutdown at startup error clean

Daniel-Constantin Mierla authored on 21/04/2014 15:50:53
Showing 1 changed files
... ...
@@ -124,6 +124,8 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
124 124
 							*((char**)ptr) = pkg_malloc(strlen((char*)val2)+1);
125 125
 							if (!*((char**)ptr)) {
126 126
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
127
+								regfree(&preg);
128
+								pkg_free(reg);
127 129
 								return -1;
128 130
 							}
129 131
 							strcpy(*((char**)ptr), (char*)val2);
... ...
@@ -133,6 +135,8 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
133 133
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
134 134
 							if (!((str*)ptr)->s) {
135 135
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
136
+								regfree(&preg);
137
+								pkg_free(reg);
136 138
 								return -1;
137 139
 							}
138 140
 							memcpy(((str*)ptr)->s, ((str*)val2)->s, ((str*)val2)->len);