From 43322985e3b4d6bce51dd3f5513680ebb3602070 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Tue, 11 Feb 2020 20:39:34 +0100 Subject: [PATCH] Fix crash when selected file has not ext --- FileBrowser/ImGuiFileBrowser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FileBrowser/ImGuiFileBrowser.cpp b/FileBrowser/ImGuiFileBrowser.cpp index 756e386..be90afe 100644 --- a/FileBrowser/ImGuiFileBrowser.cpp +++ b/FileBrowser/ImGuiFileBrowser.cpp @@ -10,9 +10,9 @@ #include #if defined (WIN32) || defined (_WIN32) || defined (__WIN32) -#define OSWIN -#ifndef NOMINMAX - #define NOMINMAX +#define OSWIN +#ifndef NOMINMAX + #define NOMINMAX #endif #include "Dirent/dirent.h" #include @@ -653,9 +653,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)