[Connection] Fix ASAN crash issue (#5625)
authorSeonah Moon <31679495+SeonahMoon@users.noreply.github.com>
Tue, 17 Oct 2023 07:16:24 +0000 (16:16 +0900)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 07:16:24 +0000 (16:16 +0900)
src/Tizen.Network.Connection/Interop/Interop.Glib.cs [new file with mode: 0644]
src/Tizen.Network.Connection/Interop/Interop.Libraries.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs
src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs

diff --git a/src/Tizen.Network.Connection/Interop/Interop.Glib.cs b/src/Tizen.Network.Connection/Interop/Interop.Glib.cs
new file mode 100644 (file)
index 0000000..a4961a7
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Glib
+    {
+        [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern uint Free(IntPtr data);
+    }
+}
index e4c5317..4963b17 100644 (file)
@@ -20,5 +20,6 @@ internal static partial class Interop
     {
         public const string Connection = "libcapi-network-connection.so.1";
         public const string Libc = "libc.so.6";
+        public const string Glib = "libglib-2.0.so.0";
     }
 }
index 91503be..7969f7f 100755 (executable)
@@ -63,7 +63,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
             }
 
@@ -112,7 +112,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get home url, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
             }
 
index a622a28..637f3c0 100644 (file)
@@ -479,7 +479,7 @@ namespace Tizen.Network.Connection
             }
 
             string result = Marshal.PtrToStringAnsi(ip);
-            Interop.Libc.Free(ip);
+            Interop.Glib.Free(ip);
             Log.Info(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")");
             if (result.Length == 0)
             {
@@ -535,7 +535,7 @@ namespace Tizen.Network.Connection
             }
 
             string result = Marshal.PtrToStringAnsi(ip);
-            Interop.Libc.Free(ip);
+            Interop.Glib.Free(ip);
             return result;
         }
 
@@ -553,7 +553,7 @@ namespace Tizen.Network.Connection
             }
 
             string result = Marshal.PtrToStringAnsi(mac);
-            Interop.Libc.Free(mac);
+            Interop.Glib.Free(mac);
             return result;
         }
 
index df518f9..362e10f 100755 (executable)
@@ -196,7 +196,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get id of connection profile, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
             }
         }
@@ -217,7 +217,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get name of connection profile, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
             }
         }
@@ -257,7 +257,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
             }
         }
@@ -391,7 +391,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(Value);
-                Interop.Libc.Free(Value);
+                Interop.Glib.Free(Value);
                 return result;
 
             }
index ec3ec8f..d9d50c2 100755 (executable)
@@ -353,7 +353,7 @@ namespace Tizen.Network.Connection
             string addr = Marshal.PtrToStringAnsi(addrPtr);
             if (addr == null || addr.Length == 0)
                 return DefaultIPAddress();
-            Interop.Libc.Free(addrPtr);
+            Interop.Glib.Free(addrPtr);
             return System.Net.IPAddress.Parse(addr);
         }
 
index 6cfbc33..df370be 100755 (executable)
@@ -55,7 +55,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(value);
-                Interop.Libc.Free(value);
+                Interop.Glib.Free(value);
                 return result;
             }
         }
@@ -76,7 +76,7 @@ namespace Tizen.Network.Connection
                     Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret);
                 }
                 string result = Marshal.PtrToStringAnsi(value);
-                Interop.Libc.Free(value);
+                Interop.Glib.Free(value);
                 return result;
             }
         }