mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: protect against unlimited recursion in Checker.ensure_generic_type_specify_type_names
This commit is contained in:
parent
2034dcb4ed
commit
75d6cb9c3a
@ -87,6 +87,7 @@ mut:
|
|||||||
// increases for `x := optfn() or { statement_list3 }`;
|
// increases for `x := optfn() or { statement_list3 }`;
|
||||||
files []ast.File
|
files []ast.File
|
||||||
expr_level int // to avoid infinite recursion segfaults due to compiler bugs
|
expr_level int // to avoid infinite recursion segfaults due to compiler bugs
|
||||||
|
ensure_generic_type_level int // to avoid infinite recursion segfaults in ensure_generic_type_specify_type_names
|
||||||
cur_orm_ts ast.TypeSymbol
|
cur_orm_ts ast.TypeSymbol
|
||||||
cur_anon_fn &ast.AnonFn = unsafe { nil }
|
cur_anon_fn &ast.AnonFn = unsafe { nil }
|
||||||
error_details []string
|
error_details []string
|
||||||
@ -4215,8 +4216,19 @@ fn (mut c Checker) trace(fbase string, message string) {
|
|||||||
fn (mut c Checker) ensure_generic_type_specify_type_names(typ ast.Type, pos token.Pos) ? {
|
fn (mut c Checker) ensure_generic_type_specify_type_names(typ ast.Type, pos token.Pos) ? {
|
||||||
if typ == 0 {
|
if typ == 0 {
|
||||||
c.error('unknown type', pos)
|
c.error('unknown type', pos)
|
||||||
return
|
return none
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.ensure_generic_type_level++
|
||||||
|
defer {
|
||||||
|
c.ensure_generic_type_level--
|
||||||
|
}
|
||||||
|
if c.ensure_generic_type_level > checker.expr_level_cutoff_limit {
|
||||||
|
c.error('checker: too many levels of Checker.ensure_generic_type_specify_type_names calls: ${c.ensure_generic_type_level} ',
|
||||||
|
pos)
|
||||||
|
return none
|
||||||
|
}
|
||||||
|
|
||||||
sym := c.table.final_sym(typ)
|
sym := c.table.final_sym(typ)
|
||||||
match sym.kind {
|
match sym.kind {
|
||||||
.function {
|
.function {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user