summaryrefslogtreecommitdiff
path: root/components/finsh/shell.c
diff options
context:
space:
mode:
authormisonyo <[email protected]>2019-03-13 22:05:03 +0800
committerGitHub <[email protected]>2019-03-13 22:05:03 +0800
commit14e048aa8e7cfd292d44aad762328b59dee53495 (patch)
treec54beac2f7c99a29311fee7e1181a0e433458511 /components/finsh/shell.c
parenta0df6bea81390d23a0ef3c8aae137048fe6ebc5f (diff)
[components/shell] shell will not work if ch is none zero as random value in stack
The serial getchar will only modify the LSB of ch, the MSB 3 bytes will be unchanged as the random value on stack, so if MSB 3 bytes not zero, the value got is wrong.
Diffstat (limited to 'components/finsh/shell.c')
-rw-r--r--components/finsh/shell.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 61c8d3dd15..1033e2c998 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -139,7 +139,7 @@ static int finsh_getchar(void)
#ifdef RT_USING_POSIX
return getchar();
#else
- int ch;
+ int ch = 0;
RT_ASSERT(shell != RT_NULL);
while (rt_device_read(shell->device, -1, &ch, 1) != 1)