mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
fix error handling in WideCharToMultiByte
(cherry picked from commit ead32c706d
)
This commit is contained in:

committed by
Sam Lantinga

parent
5cf924420d
commit
72d5eb0ecb
@@ -261,7 +261,7 @@ void windows_ShowFileDialog(void *ptr)
|
|||||||
|
|
||||||
chosen_files_list[nfiles] = NULL;
|
chosen_files_list[nfiles] = NULL;
|
||||||
|
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) >= MAX_PATH) {
|
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) == 0) {
|
||||||
SDL_SetError("Path too long or invalid character in path");
|
SDL_SetError("Path too long or invalid character in path");
|
||||||
SDL_free(chosen_files_list);
|
SDL_free(chosen_files_list);
|
||||||
callback(userdata, NULL, -1);
|
callback(userdata, NULL, -1);
|
||||||
@@ -295,7 +295,7 @@ void windows_ShowFileDialog(void *ptr)
|
|||||||
|
|
||||||
int diff = ((int) chosen_folder_size) + 1;
|
int diff = ((int) chosen_folder_size) + 1;
|
||||||
|
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) >= MAX_PATH - diff) {
|
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) == 0) {
|
||||||
SDL_SetError("Path too long or invalid character in path");
|
SDL_SetError("Path too long or invalid character in path");
|
||||||
|
|
||||||
for (size_t i = 0; i < nfiles - 1; i++) {
|
for (size_t i = 0; i < nfiles - 1; i++) {
|
||||||
|
Reference in New Issue
Block a user