Fix memory leak on cpp object api (#5761)
authorxtrm0 <afonso.tfaria21@gmail.com>
Wed, 12 Feb 2020 20:12:45 +0000 (20:12 +0000)
committerGitHub <noreply@github.com>
Wed, 12 Feb 2020 20:12:45 +0000 (12:12 -0800)
commit54f8b787cbdac587b1c9fec1ffe5a2ad2f0d61a2
treef58c6bec9f1956bb08e37a591d0befc12ae2eb2c
parent17557f913108649f98d374c6a55f2010922ca6c2
Fix memory leak on cpp object api (#5761)

Previously UnPack would allocate data with new and assign it to a
raw pointer. This behavior makes it possible for the pointer to be
leaked in case of OOM. This commit defaults to use the user specified
pointer (which needs to implement a move constructor, a .get() and a
 .release() operators), thus preventing these leaks.
samples/monster_generated.h
src/flatc.cpp
src/idl_gen_cpp.cpp
tests/arrays_test_generated.h
tests/cpp17/generated_cpp17/monster_test_generated.h
tests/monster_extra_generated.h
tests/monster_test_generated.h
tests/namespace_test/namespace_test1_generated.h
tests/namespace_test/namespace_test2_generated.h
tests/native_type_test_generated.h
tests/union_vector/union_vector_generated.h