瀏覽代碼

Check param for NULL before using

Serj Kalichev 10 年之前
父節點
當前提交
92c067e32d
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      clish/shell/shell_parse.c

+ 2 - 2
clish/shell/shell_parse.c

@@ -91,7 +91,7 @@ clish_pargv_status_t clish_shell_parse_pargv(clish_pargv_t *pargv,
 
 	while (index < paramc) {
 		const char *arg = NULL;
-		clish_param_t *param = clish_paramv__get_param(paramv,index);
+		clish_param_t *param = clish_paramv__get_param(paramv, index);
 		clish_param_t *cparam = NULL;
 		int is_switch = 0;
 
@@ -110,7 +110,7 @@ clish_pargv_status_t clish_shell_parse_pargv(clish_pargv_t *pargv,
 		}
 
 		/* Add param for help and completion */
-		if (last && (*idx == need_index) &&
+		if (param && last && (*idx == need_index) &&
 			(NULL == clish_pargv_find_arg(pargv, clish_param__get_name(param)))) {
 			if (is_switch) {
 				unsigned rec_paramc = clish_param__get_param_count(param);