Browse Source

Settings: Fixed out-of-bounds read when .ini file on disk is empty. (#5351)

Quantum 3 years ago
parent
commit
e23c5edd5f
2 changed files with 3 additions and 1 deletions
  1. 1 0
      docs/CHANGELOG.txt
  2. 2 1
      imgui.cpp

+ 1 - 0
docs/CHANGELOG.txt

@@ -94,6 +94,7 @@ Other Changes:
   always lead to menu closure. Fixes using items that are not MenuItem() or BeginItem() at the root
   level of a popup with a child menu opened.
 - Stack Tool: Added option to copy item path to clipboard. (#4631)
+- Settings: Fixed out-of-bounds read when .ini file on disk is empty. (#5351) [@quantum5]
 - DrawList: Fixed PathArcTo() emitting terminating vertices too close to arc vertices. (#4993) [@thedmd]
 - DrawList: Fixed texture-based anti-aliasing path with RGBA textures (#5132, #3245) [@cfillion]
 - DrawList: Fixed divide-by-zero or glitches with Radius/Rounding values close to zero. (#5249, #5293, #3491)

+ 2 - 1
imgui.cpp

@@ -11652,7 +11652,8 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
     char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
     if (!file_data)
         return;
-    LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
+    if (file_data_size > 0)
+        LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
     IM_FREE(file_data);
 }