Skip to content

Commit ead32c7

Browse files
kyle-sylvestreslouken
authored andcommitted
fix error handling in WideCharToMultiByte
1 parent 8ddb074 commit ead32c7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/dialog/windows/SDL_windowsdialog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void windows_ShowFileDialog(void *ptr)
261261

262262
chosen_files_list[nfiles] = NULL;
263263

264-
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) >= MAX_PATH) {
264+
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_folder, MAX_PATH, NULL, NULL) == 0) {
265265
SDL_SetError("Path too long or invalid character in path");
266266
SDL_free(chosen_files_list);
267267
callback(userdata, NULL, -1);
@@ -295,7 +295,7 @@ void windows_ShowFileDialog(void *ptr)
295295

296296
int diff = ((int) chosen_folder_size) + 1;
297297

298-
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) >= MAX_PATH - diff) {
298+
if (WideCharToMultiByte(CP_UTF8, 0, file_ptr, -1, chosen_file + diff, MAX_PATH - diff, NULL, NULL) == 0) {
299299
SDL_SetError("Path too long or invalid character in path");
300300

301301
for (size_t i = 0; i < nfiles - 1; i++) {

0 commit comments

Comments
 (0)