Browse Source

LibCore: Handle null lines in ConfigFile

Fixes nullptr dereference when trying to read binary files.
Maciej 3 years ago
parent
commit
0badfd7b32
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Userland/Libraries/LibCore/ConfigFile.cpp

+ 6 - 0
Userland/Libraries/LibCore/ConfigFile.cpp

@@ -76,6 +76,12 @@ void ConfigFile::reparse()
 
     while (m_file->can_read_line()) {
         auto line = m_file->read_line();
+
+        if (line.is_null()) {
+            m_groups.clear();
+            return;
+        }
+
         auto* cp = line.characters();
 
         while (*cp && (*cp == ' ' || *cp == '\t' || *cp == '\n'))