From c4ba502f57819633569b2d6bd00519de71556113 Mon Sep 17 00:00:00 2001 From: rw Date: Sat, 20 Aug 2016 20:33:36 -0700 Subject: [PATCH] Remove invalid vector item heap alloc Fixes #3986 --- src/idl_gen_go.cpp | 3 --- tests/MyGame/Example/Monster.go | 6 ------ 2 files changed, 9 deletions(-) diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp index 573300980..2df8c7b62 100644 --- a/src/idl_gen_go.cpp +++ b/src/idl_gen_go.cpp @@ -288,9 +288,6 @@ static void GetMemberOfVectorOfStruct(const StructDef &struct_def, if (!(vectortype.struct_def->fixed)) { code += "\t\tx = rcv._tab.Indirect(x)\n"; } - code += "\t\tif obj == nil {\n"; - code += "\t\t\tobj = new(" + TypeName(field) + ")\n"; - code += "\t\t}\n"; code += "\t\tobj.Init(rcv._tab.Bytes, x)\n"; code += "\t\treturn true\n\t}\n"; code += "\treturn false\n"; diff --git a/tests/MyGame/Example/Monster.go b/tests/MyGame/Example/Monster.go index 7ba062fdc..8ffbb7d07 100644 --- a/tests/MyGame/Example/Monster.go +++ b/tests/MyGame/Example/Monster.go @@ -131,9 +131,6 @@ func (rcv *Monster) Test4(obj *Test, j int) bool { if o != 0 { x := rcv._tab.Vector(o) x += flatbuffers.UOffsetT(j) * 4 - if obj == nil { - obj = new(Test) - } obj.Init(rcv._tab.Bytes, x) return true } @@ -173,9 +170,6 @@ func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool { x := rcv._tab.Vector(o) x += flatbuffers.UOffsetT(j) * 4 x = rcv._tab.Indirect(x) - if obj == nil { - obj = new(Monster) - } obj.Init(rcv._tab.Bytes, x) return true }