diff options
| author | Daniel Martí <mvdan@mvdan.cc> | 2017-05-10 13:53:39 +0200 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2017-05-10 13:44:53 +0000 |
| commit | 9bced47706f605c3d1b75d694dd3c9fb771ce7ba (patch) | |
| tree | 78d2d1db04517936a1ff2eef9c3c9ba632a55ee2 /src/bytes | |
| parent | 8304d10763650eb3f50553fa689500f09d8fdd06 (diff) | |
| download | go-9bced47706f605c3d1b75d694dd3c9fb771ce7ba.tar.xz | |
reflect: don't panic in ArrayOf if elem size is 0
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: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/bytes')
0 files changed, 0 insertions, 0 deletions
