From e23c5edd5fdef85ea0f5418b1368adb94bf86230 Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 27 May 2022 01:27:25 -0400 Subject: [PATCH] Settings: Fixed out-of-bounds read when .ini file on disk is empty. (#5351) --- docs/CHANGELOG.txt | 1 + imgui.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d14e4288848d..5211bf5c198f 100644 --- a/docs/CHANGELOG.txt +++ b/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) diff --git a/imgui.cpp b/imgui.cpp index 632df570a6ef..eb2eb18f8f5a 100644 --- a/imgui.cpp +++ b/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); }