Closed NQNStudios closed 1 year ago
Ugh, why is that function using manual memory management!? It looks like this change will leak the temporary buffer used for the path.
And that's just one of the problems. It should probably be migrated to Get{Open,Save}FileNameW() instead to properly handle Unicode paths… but that's out of scope for this now.
Closing in favor of #305.
If it compiles, this should fix #268.
According to this documentation:
https://learn.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getopenfilenamea https://learn.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-getsavefilenamea https://learn.microsoft.com/en-us/windows/win32/api/commdlg/nf-commdlg-commdlgextendederror
When Get{Open/Save}FileNameA() finishes with the Cancel input, the function returns false and the error code is 0.
So the code had 2 problems before: 1) not checking for the cancel code 0, and 2) not returning an empty string on error.
Someone needs to test this on Windows