Add null check to solve svace issue (#362)
[platform/core/dotnet/launcher.git] / Managed / Tizen.Runtime / Preloader.cs
index 63a4a76..8c8f30b 100644 (file)
@@ -39,11 +39,19 @@ namespace Tizen.Runtime
         {
             CheckAsciiCasing();
 
+            if (!Directory.Exists(preloadPath))
+                return;
+
             string[] paths = Directory.GetFiles(preloadPath, "*.preload");
             Array.Sort(paths);
             foreach (string path in paths)
             {
                 string fileName = Path.GetFileName(path);
+
+                // GetFileName() can return NULL
+                if (fileName == null)
+                    continue;
+
                 // ex) Tizen.preload / 0A.Tizen.preload / A0.Tizen.preload / .0.Tizen.preload / .00.Tizen.preload
                 if (!char.IsNumber(fileName, 0) || !char.IsNumber(fileName, 1))
                     continue;
@@ -97,11 +105,19 @@ namespace Tizen.Runtime
                             Assembly asm = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(assemblyStr));
                             Type type = asm.GetType(typenameStr);
                             if (type == null)
+                            {
                                 Console.WriteLine("[Warning] Check the '" + line + "' in " + fileName);
+                                continue;
+                            }
 
                             if (methodStr != "")
                             {
                                 MethodInfo method = type.GetMethod(methodStr, bindingFlag);
+                                if (method == null)
+                                {
+                                    Console.WriteLine("[Warning] Check the '" + line + "' in " + fileName);
+                                    continue;
+                                }
                                 method.Invoke(null, null);
                             }
                         }