Skip to content

Commit

Permalink
internal/jsre: handle null and undefined to prevent crash (#23701)
Browse files Browse the repository at this point in the history
This prevents the console from crashing when auto-completing on
a variable or property that is null or undefined.

Fixes #23693
  • Loading branch information
aditya520 committed Oct 10, 2021
1 parent 1bea4b0 commit a6a0609
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/jsre/completion.go
Expand Up @@ -44,7 +44,7 @@ func getCompletions(vm *goja.Runtime, line string) (results []string) {
obj := vm.GlobalObject()
for i := 0; i < len(parts)-1; i++ {
v := obj.Get(parts[i])
if v == nil {
if v == nil || goja.IsNull(v) || goja.IsUndefined(v) {
return nil // No object was found
}
obj = v.ToObject(vm)
Expand Down

0 comments on commit a6a0609

Please sign in to comment.