mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
fixes #165 - crash exporting an array with undefined as the first element
This commit is contained in:
parent
53221230c2
commit
da054efc5f
4
value.go
4
value.go
|
@ -690,7 +690,9 @@ func (self Value) export() interface{} {
|
|||
}
|
||||
value := object.get(name).export()
|
||||
t = reflect.TypeOf(value)
|
||||
if state == 0 {
|
||||
if t == nil {
|
||||
state = 2
|
||||
} else if state == 0 {
|
||||
kind = t.Kind()
|
||||
state = 1
|
||||
} else if state == 1 && kind != t.Kind() {
|
||||
|
|
|
@ -237,6 +237,12 @@ func TestExport(t *testing.T) {
|
|||
is(value[5], nil)
|
||||
is(value[5], interface{}(nil))
|
||||
}
|
||||
{
|
||||
value := test(`[ undefined, null ];`).export().([]interface{})
|
||||
is(value[0], nil)
|
||||
is(value[1], nil)
|
||||
is(value[1], interface{}(nil))
|
||||
}
|
||||
|
||||
roundtrip := []interface{}{
|
||||
true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user