Skip to content

Commit

Permalink
Fix crash when selected file has not ext
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed Feb 11, 2020
1 parent 652667c commit 4332298
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions FileBrowser/ImGuiFileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <cmath>

#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 <windows.h>
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4332298

Please sign in to comment.