• Daniel Martí's avatar
    reflect: don't panic in ArrayOf if elem size is 0 · 9bced477
    Daniel Martí authored
    We do a division by the elem type size to check if the array size would
    be too large for the virtual address space. This is a silly check if the
    size is 0, but the problem is that it means a division by zero and a
    panic.
    
    Since arrays of empty structs are valid in a regular program, make them
    also work in reflect.
    
    Use a separate, explicit test with struct{}{} to make sure the test for
    a zero-sized type is not confused with the rest.
    
    Fixes #20313.
    
    Change-Id: I47b8b87e6541631280b79227bdea6a0f6035c9e0
    Reviewed-on: https://go-review.googlesource.com/43131
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    9bced477
Name
Last commit
Last update
..
all_test.go Loading commit data...
asm_386.s Loading commit data...
asm_amd64.s Loading commit data...
asm_amd64p32.s Loading commit data...
asm_arm.s Loading commit data...
asm_arm64.s Loading commit data...
asm_mips64x.s Loading commit data...
asm_mipsx.s Loading commit data...
asm_ppc64x.s Loading commit data...
asm_s390x.s Loading commit data...
deepequal.go Loading commit data...
example_test.go Loading commit data...
export_test.go Loading commit data...
makefunc.go Loading commit data...
set_test.go Loading commit data...
swapper.go Loading commit data...
tostring_test.go Loading commit data...
type.go Loading commit data...
value.go Loading commit data...