Fix defects detected by static analysis tool 74/318574/2
authorMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Wed, 2 Oct 2024 08:34:44 +0000 (14:34 +0600)
committerMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Thu, 3 Oct 2024 05:10:49 +0000 (11:10 +0600)
[Problem] [TNINE-4742] Issues detected by Static Analysis Tool
[Cause & Measure]
 Cause   : Assembly.Load expects byte array as argument
           tabButtonStyle was not disposed
 Measure : Added byte array as argument to Assembly.Load.
   tabButonStyle is not disposed OnDestroy.

Change-Id: I90b911f1b231444aa1fb2a9b967cf99bbbbd6ed0
Signed-off-by: Md. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
SettingCore/GadgetProvider.cs
SettingMainGadget/SettingMainGadget/About/AboutUserCertificatesGadget.cs

index 896856d20733aca4739be8743961977746eaca1e..78789cf1a929a55ea5d43e10149d86311f30853b 100644 (file)
@@ -64,11 +64,12 @@ namespace SettingCore
         private static IEnumerable<SettingGadgetInfo> getSettingGadgetInfos(NUIGadgetInfo gadgetInfo)
         {
             string assemblyPath = System.IO.Path.Combine(gadgetInfo.ResourcePath, gadgetInfo.ExecutableFile);
+            byte[] fileData = System.IO.File.ReadAllBytes(assemblyPath);
             Assembly assembly = null;
             try
             {
                 Logger.Verbose($"Opening assembly from {assemblyPath} ({gadgetInfo.ResourcePath}, {gadgetInfo.ExecutableFile})");
-                assembly = Assembly.Load(System.IO.File.ReadAllBytes(assemblyPath));
+                assembly = System.Reflection.Assembly.Load(fileData);
             }
             catch (System.IO.FileLoadException)
             {
index 8c93c8349fd8a070f8b624ccc692fe5bcc0018c2..eb431f694c5f62e5addd324b6aba0fb4e8de7dc6 100644 (file)
@@ -21,7 +21,7 @@ namespace Setting.Menu.About
         private ScrollableBase vpnTabContent, wifiTabContent, emailTabContent;
 
         private MoreMenuItem installMenuItem, uninstallMenuItem;
-
+        private TabButtonStyle tabButtonStyle;
         public override string ProvideTitle() => "User certificates";
 
         public override IEnumerable<MoreMenuItem> ProvideMoreMenu() => Moremenu();
@@ -83,7 +83,7 @@ namespace Setting.Menu.About
                 HeightSpecification = LayoutParamPolicies.MatchParent,
             };
 
-            var tabButtonStyle = ThemeManager.GetStyle("Tizen.NUI.Components.TabButton") as TabButtonStyle;
+            tabButtonStyle = ThemeManager.GetStyle("Tizen.NUI.Components.TabButton") as TabButtonStyle;
             tabButtonStyle.Padding = new Extents(2, 2, 16, 16).SpToPx();
             tabButtonStyle.Icon.Size = new Size(2, -1).SpToPx();
 
@@ -231,6 +231,7 @@ namespace Setting.Menu.About
             Logger.Debug("OnDestroy()");
 
             base.OnDestroy();
+            tabButtonStyle.dispose();
         }
     }
 }