internal/jsre: handle null and undefined to prevent crash (#23701)

This prevents the console from crashing when auto-completing on
a variable or property that is null or undefined.

Fixes #23693
verkle/onleaf
Aditya Arora 3 years ago committed by GitHub
parent 1bea4b0dfa
commit a6a0609b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      internal/jsre/completion.go

@ -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)

Loading…
Cancel
Save