2
0
Эх сурвалжийг харах

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

- keep shutdown at startup error clean
Daniel-Constantin Mierla 11 жил өмнө
parent
commit
b1106fb492
1 өөрчлөгдсөн 4 нэмэгдсэн , 0 устгасан
  1. 4 0
      modparam.c

+ 4 - 0
modparam.c

@@ -124,6 +124,8 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
 							*((char**)ptr) = pkg_malloc(strlen((char*)val2)+1);
 							*((char**)ptr) = pkg_malloc(strlen((char*)val2)+1);
 							if (!*((char**)ptr)) {
 							if (!*((char**)ptr)) {
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
+								regfree(&preg);
+								pkg_free(reg);
 								return -1;
 								return -1;
 							}
 							}
 							strcpy(*((char**)ptr), (char*)val2);
 							strcpy(*((char**)ptr), (char*)val2);
@@ -133,6 +135,8 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
 							((str*)ptr)->s = pkg_malloc(((str*)val2)->len+1);
 							if (!((str*)ptr)->s) {
 							if (!((str*)ptr)->s) {
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
 								LOG(L_ERR, "set_mod_param_regex(): No memory left\n");
+								regfree(&preg);
+								pkg_free(reg);
 								return -1;
 								return -1;
 							}
 							}
 							memcpy(((str*)ptr)->s, ((str*)val2)->s, ((str*)val2)->len);
 							memcpy(((str*)ptr)->s, ((str*)val2)->s, ((str*)val2)->len);