Browse Source

Fixed potential ArgumentOutOfRangeException in LinuxOSInformation.FromReleaseFile()

CPKreuz 4 months ago
parent
commit
84aa46733a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/PixiEditor.Linux/LinuxOperatingSystem.cs

+ 4 - 1
src/PixiEditor.Linux/LinuxOperatingSystem.cs

@@ -68,7 +68,10 @@ public sealed class LinuxOperatingSystem : IOperatingSystem
             var lines = File.ReadAllLines(FilePath).Select<string, (string? Key, string Value)>(line =>
             var lines = File.ReadAllLines(FilePath).Select<string, (string? Key, string Value)>(line =>
             {
             {
                 var separatorIndex = line.IndexOf('=');
                 var separatorIndex = line.IndexOf('=');
-                return (line[..separatorIndex], line[(separatorIndex + 1)..]);
+                
+                return separatorIndex != -1 
+                    ? (line[..separatorIndex], line[(separatorIndex + 1)..])
+                    : (null, null);
             }).ToList();
             }).ToList();
             
             
             var name = GetKeyValue("NAME") ?? GetKeyValue("ID");
             var name = GetKeyValue("NAME") ?? GetKeyValue("ID");