From 707349c2f428f208aa431edbeadf98ead40bfb9e Mon Sep 17 00:00:00 2001 From: Nolan Kramer Date: Tue, 24 Sep 2024 17:48:54 -0700 Subject: [PATCH] Fix naked_ptr issue --- src/idl_gen_cpp.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 06571693286e..7eb16e05be0a 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -3380,14 +3380,18 @@ class CppGenerator : public BaseGenerator { if (is_pointer) { code += "{ if(" + out_field + ") { "; - code += "_e->UnPackTo(" + out_field + ".get(), _resolver);"; + code += "_e->UnPackTo(" + out_field + GenPtrGet(field) + ", _resolver);"; code += " } else { "; } code += out_field + " = "; code += GenUnpackVal(field.value.type, "_e", false, field) + ";"; if (is_pointer) { - code += " } } else if (" + out_field + ") { " + out_field + - ".reset(); }"; + code += " } } else if (" + out_field + ") { " + out_field; + if (PtrType(&field) == "naked") { + code += " = nullptr; }"; + } else { + code += ".reset(); }"; + } } } break;