Browse Source

Address memory heap corruption on Windows open dialog on long filenames (#1544)

fixes #1513
DarioSamo 5 years ago
parent
commit
238d52c90f
2 changed files with 2 additions and 2 deletions
  1. 1 1
      include/igl/file_dialog_open.cpp
  2. 1 1
      include/igl/file_dialog_save.cpp

+ 1 - 1
include/igl/file_dialog_open.cpp

@@ -60,7 +60,7 @@ IGL_INLINE std::string igl::file_dialog_open()
   ZeroMemory(&ofn, sizeof(ofn));
   ZeroMemory(&ofn, sizeof(ofn));
   ofn.lStructSize = sizeof(ofn);
   ofn.lStructSize = sizeof(ofn);
   ofn.hwndOwner = NULL;
   ofn.hwndOwner = NULL;
-  ofn.lpstrFile = new char[100];
+  ofn.lpstrFile = szFile;
   // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
   // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
   // use the contents of szFile to initialize itself.
   // use the contents of szFile to initialize itself.
   ofn.lpstrFile[0] = '\0';
   ofn.lpstrFile[0] = '\0';

+ 1 - 1
include/igl/file_dialog_save.cpp

@@ -60,7 +60,7 @@ IGL_INLINE std::string igl::file_dialog_save()
   ZeroMemory(&ofn, sizeof(ofn));
   ZeroMemory(&ofn, sizeof(ofn));
   ofn.lStructSize = sizeof(ofn);
   ofn.lStructSize = sizeof(ofn);
   ofn.hwndOwner = NULL;//hwnd;
   ofn.hwndOwner = NULL;//hwnd;
-  ofn.lpstrFile = new char[100];
+  ofn.lpstrFile = szFile;
   // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
   // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
   // use the contents of szFile to initialize itself.
   // use the contents of szFile to initialize itself.
   ofn.lpstrFile[0] = '\0';
   ofn.lpstrFile[0] = '\0';