From 41674b9fe4c0beb00ac29c32a2085fa670e863a9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 19 Nov 2013 02:30:03 +0000 Subject: reflect: Handle calls to functions that take or return empty structs Fixes issue 6761 This simple change seems to work fine, slightly to my surprise. This includes the tests I submitted to the main Go repository at https://codereview.appspot.com/26570046 From-SVN: r205001 --- libgo/runtime/go-reflect-call.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libgo/runtime/go-reflect-call.c') diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index 0fed68a..07b99d7 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -98,9 +98,12 @@ go_struct_to_ffi (const struct __go_struct_type *descriptor) const struct __go_struct_field *fields; int i; + field_count = descriptor->__fields.__count; + if (field_count == 0) { + return &ffi_type_void; + } ret = (ffi_type *) __go_alloc (sizeof (ffi_type)); ret->type = FFI_TYPE_STRUCT; - field_count = descriptor->__fields.__count; fields = (const struct __go_struct_field *) descriptor->__fields.__values; ret->elements = (ffi_type **) __go_alloc ((field_count + 1) * sizeof (ffi_type *)); -- cgit v1.1