浏览代码

fix some bugs in finsh for NULL node.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@455 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 15 年之前
父节点
当前提交
8aaddbaf38
共有 2 个文件被更改,包括 13 次插入4 次删除
  1. 11 4
      finsh/finsh_parser.c
  2. 2 0
      finsh/shell.c

+ 11 - 4
finsh/finsh_parser.c

@@ -656,8 +656,11 @@ static struct finsh_node* proc_cast_expr(struct finsh_parser* self)
 		match_token(token, &(self->token), finsh_token_type_right_paren);
 		match_token(token, &(self->token), finsh_token_type_right_paren);
 
 
 		cast = proc_cast_expr(self);
 		cast = proc_cast_expr(self);
-		cast->data_type = type;
-		return cast;
+		if (cast != NULL)
+		{
+			cast->data_type = type;
+			return cast;
+		}
 	}
 	}
 
 
 	finsh_token_replay(&(self->token));
 	finsh_token_replay(&(self->token));
@@ -835,6 +838,7 @@ static struct finsh_node* proc_param_list(struct finsh_parser* self)
 	struct finsh_node *node, *assign;
 	struct finsh_node *node, *assign;
 
 
 	assign = proc_assign_expr(self);
 	assign = proc_assign_expr(self);
+	if (assign == NULL) return NULL;
 	node = assign;
 	node = assign;
 
 
 	next_token(token, &(self->token));
 	next_token(token, &(self->token));
@@ -867,8 +871,11 @@ static struct finsh_node* make_sys_node(u_char type, struct finsh_node* node1, s
 
 
 	node = finsh_node_allocate(type);
 	node = finsh_node_allocate(type);
 
 
-	finsh_node_child(node) = node1;
-	if (node1 != NULL) finsh_node_sibling(node1) = node2;
+	if (node1 != NULL)
+	{
+		finsh_node_child(node) = node1;
+		finsh_node_sibling(node1) = node2;
+	}
 	else finsh_error_set(FINSH_ERROR_NULL_NODE);
 	else finsh_error_set(FINSH_ERROR_NULL_NODE);
 
 
 	return node;
 	return node;

+ 2 - 0
finsh/shell.c

@@ -326,6 +326,8 @@ void finsh_thread_entry(void* parameter)
 						continue;
 						continue;
 					}
 					}
 
 
+					if (pos >= 256) /* it's a large line, discard it */
+						pos = 0;
 					line[pos] = ch;
 					line[pos] = ch;
 
 
 					rt_kprintf("%c", line[pos]);
 					rt_kprintf("%c", line[pos]);