From: Hwankyu Jhun Date: Fri, 1 Jun 2018 09:23:44 +0000 (+0900) Subject: Fix resource leak and change the type X-Git-Tag: accepted/tizen/unified/20180611.015340~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6703114dc62cd1faf44f982884986ac099eff42f;p=platform%2Fcore%2Fappfw%2Ftidl.git Fix resource leak and change the type - Releases the allocated memory before throwing the exception - Changes the seqNum to volatile type Change-Id: Id09fd26b1b00e9bc407998f4c0b1571a85d76ecf Signed-off-by: Hwankyu Jhun --- diff --git a/idlc/cs_gen/cs_gen_base_cb.h b/idlc/cs_gen/cs_gen_base_cb.h index d80bd7e..4435e49 100644 --- a/idlc/cs_gen/cs_gen_base_cb.h +++ b/idlc/cs_gen/cs_gen_base_cb.h @@ -34,7 +34,7 @@ R"__cs_cb( internal int Id; internal int SeqId; internal bool Once; - private static int _seqNum = 0; + private static volatile int _seqNum = 0; public string Tag { diff --git a/idlc/cs_gen/cs_proxy_gen.cc b/idlc/cs_gen/cs_proxy_gen.cc index 9b127a5..5ef2c09 100644 --- a/idlc/cs_gen/cs_proxy_gen.cc +++ b/idlc/cs_gen/cs_proxy_gen.cc @@ -181,6 +181,7 @@ void CsProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) { const char* receive_block = "if (parcel_received == IntPtr.Zero)\n" \ "{\n" \ + " Interop.LibRPCPort.Parcel.Destroy(p);\n" \ " throw new InvalidProtocolException();\n" \ "}\n"; stream << AddIndent(TAB_SIZE * 4, receive_block) << NLine(1); diff --git a/idlc/cs_gen/cs_stub_gen_cb.h b/idlc/cs_gen/cs_stub_gen_cb.h index fe64861..70a0b63 100644 --- a/idlc/cs_gen/cs_stub_gen_cb.h +++ b/idlc/cs_gen/cs_stub_gen_cb.h @@ -70,8 +70,6 @@ R"__cs_cb( if (ret != Interop.LibRPCPort.ErrorCode.None) return -1; - Interop.LibRPCPort.Parcel.Create(out IntPtr result); - Interop.LibRPCPort.Parcel.ReadInt32(p, out int cmd); ServiceBase b = null; foreach (var i in _services) @@ -84,7 +82,13 @@ R"__cs_cb( } if (b == null) + { + Interop.LibRPCPort.Parcel.Destroy(p); return -1; + } + + Interop.LibRPCPort.Parcel.Create(out IntPtr result); + Interop.LibRPCPort.Parcel.ReadInt32(p, out int cmd); switch ((MethodId)cmd) { @@ -93,6 +97,8 @@ R"__cs_cb( const char CB_ON_RECEIVED_EVENT_BACK[] = R"__cs_cb( default: + Interop.LibRPCPort.Parcel.Destroy(p); + Interop.LibRPCPort.Parcel.Destroy(result); return -1; }