]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: pad structs which end in zero-sized fields
authorKeith Randall <khr@golang.org>
Wed, 7 Jan 2015 17:25:23 +0000 (09:25 -0800)
committerKeith Randall <khr@golang.org>
Thu, 8 Jan 2015 21:05:10 +0000 (21:05 +0000)
commit6f07ac2f280847ee0346b871b23cab90869f84a4
tree923f384eb4354173368bfd5fc8e727442f9cfcff
parent654a185f209439be5347ed1aae7e5ce2e75209f0
cmd/gc: pad structs which end in zero-sized fields

For a non-zero-sized struct with a final zero-sized field,
add a byte to the size (before rounding to alignment).  This
change ensures that taking the address of the zero-sized field
will not incorrectly leak the following object in memory.

reflect.funcLayout also needs this treatment.

Fixes #9401

Change-Id: I1dc503dc5af4ca22c8f8c048fb7b4541cc957e0f
Reviewed-on: https://go-review.googlesource.com/2452
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/gc/align.c
src/reflect/type.go
src/runtime/runtime_test.go