Browse Source

Check param for NULL before using

Serj Kalichev 10 years ago
parent
commit
c5797bb6bf
1 changed files with 2 additions and 2 deletions
  1. 2 2
      clish/shell/shell_parse.c

+ 2 - 2
clish/shell/shell_parse.c

@@ -92,7 +92,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;
 
@@ -111,7 +111,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);