Commits

Patrick Schaller committed afe0b99

PwEntryExtension: added null or empty check for keyFilesString.
#16

Comments (0)

Files changed (1)

src/KeepassTrueCryptMount/PwEntryExtension.cs

             // Keyfiles
             {
                 var keyFilesString = entry.Strings.GetSafe(EntryStrings.KeyFiles).ReadString();
-                String[] keyFiles = keyFilesString.Split(';');
-                for (int i = 0; i < keyFiles.Length; i++)
-                {
-                    var keyFile = keyFiles[i];
 
-                    if (string.IsNullOrEmpty(keyFile))
+                if (!string.IsNullOrEmpty(keyFilesString))
+                {
+                    string[] keyFiles = keyFilesString.Split(';');
+                    for (int i = 0; i < keyFiles.Length; i++)
                     {
-                        continue;
-                    }
+                        var keyFile = keyFiles[i];
 
-                    if (!Path.IsPathRooted(keyFile))
-                    {
-                        keyFile = SprEngine.Compile(keyFile, new SprContext(entry, null, SprCompileFlags.Paths | SprCompileFlags.EnvVars));
-                    }
+                        if (string.IsNullOrEmpty(keyFile))
+                        {
+                            continue;
+                        }
+
+                        if (!Path.IsPathRooted(keyFile))
+                        {
+                            keyFile = SprEngine.Compile(keyFile, new SprContext(entry, null, SprCompileFlags.Paths | SprCompileFlags.EnvVars));
+                        }
 
-                    arguments.Append(" /k ");
-                    arguments.Append(keyFile.GetFullPath().QuoteIfNecessary());
+                        arguments.Append(" /k ");
+                        arguments.Append(keyFile.GetFullPath().QuoteIfNecessary());
+                    }
                 }
                
             }