mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
console: fix a couple panics
This commit is contained in:
parent
2b360f25c2
commit
7cecc39fd8
2 changed files with 13 additions and 5 deletions
|
|
@ -320,7 +320,7 @@ func (re *JSRE) Compile(filename string, src string) (err error) {
|
|||
}
|
||||
|
||||
func compileAndRun(vm *goja.Runtime, filename string, src string) (goja.Value, error) {
|
||||
script, err := goja.Compile(filename, src, true)
|
||||
script, err := goja.Compile(filename, src, false)
|
||||
if err != nil {
|
||||
return goja.Null(), err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,8 +226,15 @@ func iterOwnAndConstructorKeys(vm *goja.Runtime, obj *goja.Object, f func(string
|
|||
}
|
||||
|
||||
func iterOwnKeys(vm *goja.Runtime, obj *goja.Object, f func(string)) {
|
||||
getOwnPropertyNames, _ := goja.AssertFunction(vm.Get("Object.getOwnPropertyNames"))
|
||||
rv, _ := getOwnPropertyNames(obj)
|
||||
Object := vm.Get("Object").ToObject(vm)
|
||||
getOwnPropertyNames, isFunc := goja.AssertFunction(Object.Get("getOwnPropertyNames"))
|
||||
if !isFunc {
|
||||
panic(vm.ToValue("Object.getOwnPropertyNames isn't a function"))
|
||||
}
|
||||
rv, err := getOwnPropertyNames(goja.Null(), obj)
|
||||
if err != nil {
|
||||
panic(vm.ToValue(fmt.Sprintf("Error getting object properties: %v", err)))
|
||||
}
|
||||
gv := rv.Export()
|
||||
switch gv := gv.(type) {
|
||||
case []interface{}:
|
||||
|
|
@ -251,11 +258,12 @@ func (ctx ppctx) isBigNumber(v *goja.Object) bool {
|
|||
}
|
||||
}
|
||||
// Handle default constructor.
|
||||
BigNumber := ctx.vm.Get("BigNumber.prototype").ToObject(ctx.vm)
|
||||
BigNumber := ctx.vm.Get("BigNumber").ToObject(ctx.vm)
|
||||
if BigNumber == nil {
|
||||
return false
|
||||
}
|
||||
isPrototypeOf, exists := goja.AssertFunction(BigNumber.Get("isPrototypeOf"))
|
||||
prototype := BigNumber.Get("prototype").ToObject(ctx.vm)
|
||||
isPrototypeOf, exists := goja.AssertFunction(prototype.Get("isPrototypeOf"))
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue