Skip to content

Commit aebe9bc

Browse files
committed
parser: fix panic, discovered by fuzzing examples/2048/2048.v with zzuf on the CI
1 parent 309aebf commit aebe9bc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

vlib/v/parser/containers.v

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ fn (mut p Parser) array_init(is_option bool, alias_array_type ast.Type) ast.Arra
7575
|| (p.tok.kind == .lsbr && p.is_array_type())) {
7676
// [100]u8
7777
elem_type = p.parse_type()
78-
if p.table.sym(elem_type).name == 'byte' {
79-
p.error('`byte` has been deprecated in favor of `u8`: use `[10]u8{}` instead of `[10]byte{}`')
78+
if elem_type != 0 {
79+
s := p.table.sym(elem_type)
80+
if s.name == 'byte' {
81+
p.error('`byte` has been deprecated in favor of `u8`: use `[10]u8{}` instead of `[10]byte{}`')
82+
}
8083
}
8184
last_pos = p.tok.pos()
8285
is_fixed = true

0 commit comments

Comments
 (0)