From: Changgyu Choi Date: Tue, 5 Oct 2021 08:09:55 +0000 (+0900) Subject: Fix static issue X-Git-Tag: submit/tizen/20211006.041716~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d74e003b215b64a4d287deb1e62d8b1ec6d42367;p=platform%2Fcore%2Fappfw%2Ftidl.git Fix static issue Change-Id: I49a20746e2261d64df716e2a949c914ec56f553b Signed-off-by: Changgyu Choi --- diff --git a/idlc/gen/cpp_gen_base.cc b/idlc/gen/cpp_gen_base.cc index 1e45d274..77f8ad5e 100644 --- a/idlc/gen/cpp_gen_base.cc +++ b/idlc/gen/cpp_gen_base.cc @@ -368,7 +368,11 @@ void CppGeneratorBase::GenListSerializer(std::ofstream& stream, << NLine(1); stream << Tab(1) << "for (const auto& i : c) "; GenBrace(stream, TAB_SIZE, [&]() { - auto& mt = *type.GetMetaType(); + auto* ptr = type.GetMetaType(); + if (ptr == nullptr) + return; + + auto& mt = *ptr; stream << AddIndent(TAB_SIZE * 2, ConvertTypeToSerializer(mt, "i", "h")); }, false); stream << Tab(1) << "return h;" << NLine(1); diff --git a/idlc/gen/cs_gen_base.cc b/idlc/gen/cs_gen_base.cc index 480fda82..2507315d 100644 --- a/idlc/gen/cs_gen_base.cc +++ b/idlc/gen/cs_gen_base.cc @@ -163,7 +163,10 @@ void CsGeneratorBase::GenListSerializer(std::ofstream& stream, << NLine(1); stream << Tab(4) << "foreach (var i in param)" << NLine(1); GenBrace(stream, TAB_SIZE * 4, [&]() { - auto& mt = *type.GetMetaType(); + auto* ptr = type.GetMetaType(); + if (ptr == nullptr) return; + + auto& mt = *ptr; if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) { stream << Tab(5) << "h.Write" << ConvertTypeToParcelType(mt.ToString()) diff --git a/unit_tests/type_unittest.cc b/unit_tests/type_unittest.cc index f08e7b36..677e096e 100644 --- a/unit_tests/type_unittest.cc +++ b/unit_tests/type_unittest.cc @@ -61,6 +61,7 @@ TEST_F(BaseTypeTest, BaseType_Constructor) { TEST_F(BaseTypeTest, BaseType_SetMetaType) { tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true); customType->SetMetaType(new tidl::BaseType("int", "")); + EXPECT_NE(customType->GetMetaType(), nullptr); EXPECT_EQ(customType->GetMetaType()->ToString(), "int"); delete customType; } @@ -68,6 +69,7 @@ TEST_F(BaseTypeTest, BaseType_SetMetaType) { TEST_F(BaseTypeTest, BaseType_GetMetaType) { tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true); customType->SetMetaType(new tidl::BaseType("string", "")); + EXPECT_NE(customType->GetMetaType(), nullptr); EXPECT_EQ(customType->GetMetaType()->ToString(), "string"); delete customType; }