mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 14:16:47 +00:00
fix(tty): 修复tty对tab进行处理时产生数组越界panic的问题 (#1015)
Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
parent
a9e28e9ce9
commit
4dd4856f93
@ -1284,13 +1284,11 @@ impl VirtualConsoleData {
|
||||
// 水平制表符(Horizontal Tab)
|
||||
self.pos -= self.state.x;
|
||||
|
||||
let ret = self.tab_stop.next_index(self.state.x + 1);
|
||||
|
||||
if let Some(x) = ret {
|
||||
self.state.x = x;
|
||||
} else {
|
||||
self.state.x = self.cols - 1;
|
||||
}
|
||||
self.state.x = self
|
||||
.tab_stop
|
||||
.next_index(self.state.x + 1)
|
||||
.unwrap_or(self.cols - 1);
|
||||
self.state.x = core::cmp::min(self.state.x, self.cols - 1);
|
||||
|
||||
self.pos += self.state.x;
|
||||
// TODO: notify
|
||||
@ -1552,7 +1550,7 @@ impl VirtualConsoleData {
|
||||
}
|
||||
|
||||
// 未找到
|
||||
if (!self.utf || self.display_ctrl || c < 128) && c & !charmask == 0 {
|
||||
if (!self.utf || self.display_ctrl || c < 128) && (c & !charmask) == 0 {
|
||||
tc = c;
|
||||
} else {
|
||||
let tmp = self.unicode_to_index(0xfffd);
|
||||
@ -1587,7 +1585,7 @@ impl VirtualConsoleData {
|
||||
// TODO: 处理unicode screen buf
|
||||
|
||||
if himask != 0 {
|
||||
tc = (if tc & 0x100 != 0 { himask as u32 } else { 0 }) | (tc & 0xff);
|
||||
tc = (if (tc & 0x100) != 0 { himask as u32 } else { 0 }) | (tc & 0xff);
|
||||
}
|
||||
|
||||
tc |= ((attr as u32) << 8) & (!himask as u32);
|
||||
@ -1602,7 +1600,7 @@ impl VirtualConsoleData {
|
||||
// );
|
||||
self.screen_buf[self.pos] = tc as u16;
|
||||
|
||||
if draw.x.is_none() {
|
||||
if self.should_update() && draw.x.is_none() {
|
||||
// 设置draw参数
|
||||
draw.x = Some(self.state.x as u32);
|
||||
draw.offset = self.pos;
|
||||
@ -1619,7 +1617,7 @@ impl VirtualConsoleData {
|
||||
}
|
||||
|
||||
width -= 1;
|
||||
if width == 0 {
|
||||
if width <= 0 {
|
||||
break;
|
||||
}
|
||||
let tmp = self.unicode_to_index(' ' as u32);
|
||||
@ -1629,7 +1627,6 @@ impl VirtualConsoleData {
|
||||
if invert {
|
||||
self.flush(draw);
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl FontDesc {
|
||||
}
|
||||
|
||||
for (first, last) in Self::DOUBLE_WIDTH_RANGE {
|
||||
if ch > *first && ch < *last {
|
||||
if ch >= *first && ch < *last {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user