diff options
Diffstat (limited to 'libgo/runtime/iface.goc')
-rw-r--r-- | libgo/runtime/iface.goc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libgo/runtime/iface.goc b/libgo/runtime/iface.goc index 356b318cbc8..05e37736b88 100644 --- a/libgo/runtime/iface.goc +++ b/libgo/runtime/iface.goc @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. package runtime +#include "go-panic.h" #include "go-type.h" #include "interface.h" #define nil NULL @@ -33,6 +34,8 @@ func ifacetype(i interface) (d *const_descriptor) { // Convert an empty interface to an empty interface. func ifaceE2E2(e empty_interface) (ret empty_interface, ok bool) { + if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0) + __go_panic_msg("invalid interface value"); ret = e; ok = ret.__type_descriptor != nil; } @@ -52,6 +55,8 @@ func ifaceI2E2(i interface) (ret empty_interface, ok bool) { // Convert an empty interface to a non-empty interface. func ifaceE2I2(inter *descriptor, e empty_interface) (ret interface, ok bool) { + if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0) + __go_panic_msg("invalid interface value"); if (e.__type_descriptor == nil) { ret.__methods = nil; ret.__object = nil; @@ -81,6 +86,8 @@ func ifaceI2I2(inter *descriptor, i interface) (ret interface, ok bool) { // Convert an empty interface to a pointer type. func ifaceE2T2P(inter *descriptor, e empty_interface) (ret *void, ok bool) { + if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0) + __go_panic_msg("invalid interface value"); if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) { ret = nil; ok = 0; @@ -104,6 +111,8 @@ func ifaceI2T2P(inter *descriptor, i interface) (ret *void, ok bool) { // Convert an empty interface to a non-pointer type. func ifaceE2T2(inter *descriptor, e empty_interface, ret *void) (ok bool) { + if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0) + __go_panic_msg("invalid interface value"); if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) { __builtin_memset(ret, 0, inter->__size); ok = 0; |