From d7ed00de7ac9706f90cc249e5d5d9edb2504ef59 Mon Sep 17 00:00:00 2001 From: Aditya Arora Date: Sun, 10 Oct 2021 09:58:47 -0300 Subject: [PATCH] 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 --- internal/jsre/completion.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/jsre/completion.go b/internal/jsre/completion.go index 2c105184cb08c..538fca298ddef 100644 --- a/internal/jsre/completion.go +++ b/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)