golang/xenlight: Don't try to marshall zero-length arrays in fromC
authorGeorge Dunlap <george.dunlap@citrix.com>
Thu, 26 Dec 2019 13:08:05 +0000 (13:08 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Thu, 23 Apr 2020 15:00:11 +0000 (16:00 +0100)
commitb70275d0d9fb626102a9521794f2bd75b4d420eb
treed3e6d321e630780f95a4111bf14d7afa32f73fde
parentf9e707aa97b204229dde5125116364c9e410ef67
golang/xenlight: Don't try to marshall zero-length arrays in fromC

The current fromC array code will do the "magic" casting and
martialling even when num_foo variable is 0.  Go crashes when doing
the cast.

Only do array marshalling if the number of elements is non-zero;
otherwise, leave the target pointer empty (nil for Go slices, NULL for
C arrays).

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Nick Rosbrook <rosbrookn@ainfosec.com>
tools/golang/xenlight/gengotypes.py
tools/golang/xenlight/helpers.gen.go