diff --git a/FileBrowser/ImGuiFileBrowser.cpp b/FileBrowser/ImGuiFileBrowser.cpp index cb29c4d..b492eae 100644 --- a/FileBrowser/ImGuiFileBrowser.cpp +++ b/FileBrowser/ImGuiFileBrowser.cpp @@ -720,9 +720,9 @@ namespace imgui_addons bool ImGuiFileBrowser::validateFile() { - int idx = selected_fn.find_last_of("."); - std::string ext = selected_fn.substr(idx, selected_fn.length() - idx); - return (std::find(valid_exts.begin(), valid_exts.end(), ext) != valid_exts.end()); + int idx = selected_fn.find_last_of('.'); + std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx); + return (std::find(valid_exts.begin(), valid_exts.end(), file_ext) != valid_exts.end()); } void ImGuiFileBrowser::parsePathTabs(std::string path)