[Tizen.Network.WiFi]Fix heap-use-after-free issue on ASAN image (#6397)
authorchaeheehong <chaehee.hong@samsung.com>
Thu, 10 Oct 2024 09:24:46 +0000 (18:24 +0900)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2024 09:24:46 +0000 (18:24 +0900)
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs

index 49af0cf31744390c97f9abe4a7be832fc1e479f4..b969d5085ab69896842c80b6098d43ad010591e1 100755 (executable)
@@ -32,6 +32,7 @@ namespace Tizen.Network.WiFi
         private IntPtr _configHandle = IntPtr.Zero;
         private bool _disposed = false;
         private WiFiEapConfiguration _eapConfig;
+        private readonly Object _lock = new Object();
 
         /// <summary>
         /// The name of the access point (AP).
@@ -241,12 +242,19 @@ namespace Tizen.Network.WiFi
 
         private void Dispose(bool disposing)
         {
-            if (_disposed)
-                return;
+            lock (_lock)
+            {
+                if (_disposed)
+                    return;
+
+                if (disposing)
+                {
+                    Interop.WiFi.Config.Destroy(_configHandle);
+                    _configHandle = IntPtr.Zero;
+                }
 
-            Interop.WiFi.Config.Destroy(_configHandle);
-            _configHandle = IntPtr.Zero;
-            _disposed = true;
+                _disposed = true;
+            }
         }
 
         internal IntPtr GetHandle()