瀏覽代碼

Follow up to b98fe0b
* Added a check if allocation fails.

aleos89 9 年之前
父節點
當前提交
af773a94a9
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/char/char.c

+ 4 - 0
src/char/char.c

@@ -2670,6 +2670,8 @@ static void char_config_split_startpoint(char *w2_value)
 #endif
 
 	fields = (char **)aMalloc(fields_length * sizeof(char *));
+	if (fields == NULL)
+		return; // Failed to allocate memory.
 	lineitem = strtok(w2_value, ":");
 
 	while (lineitem != NULL) {
@@ -2715,6 +2717,8 @@ static void char_config_split_startitem(char *w2_value)
 	strcat(config_name, "start_items");
 
 	fields = (char **)aMalloc(fields_length * sizeof(char *));
+	if (fields == NULL)
+		return; // Failed to allocate memory.
 	lineitem = strtok(w2_value, ":");
 
 	while (lineitem != NULL) {