From 830448549f7c455a42a3d9bb36105e616481a326 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Tue, 16 Mar 2021 17:58:33 -0300 Subject: [PATCH] Fix warning in win_settings --- src/win/win_settings.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 3fc32a960..ad47962f6 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -2720,6 +2720,8 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM img_format = settings_get_cur_sel(hdlg, IDC_COMBO_HD_IMG_FORMAT); if (img_format < 3) { f = _wfopen(hd_file_name, L"wb"); + } else { + f = (FILE *) 0; } if (img_format == 1) { /* HDI file */ @@ -2801,13 +2803,17 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM h = GetDlgItem(hdlg, IDC_PBAR_IMG_CREATE); if (size) { - fwrite(big_buf, 1, size, f); + if (f) { + fwrite(big_buf, 1, size, f); + } SendMessage(h, PBM_SETPOS, (WPARAM) 1, (LPARAM) 0); } if (r) { for (i = 0; i < r; i++) { - fwrite(big_buf, 1, 1048576, f); + if (f) { + fwrite(big_buf, 1, 1048576, f); + } SendMessage(h, PBM_SETPOS, (WPARAM) (i + 1), (LPARAM) 0); settings_process_messages(); @@ -2816,7 +2822,9 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM free(big_buf); - fclose(f); + if (f) { + fclose(f); + } settings_msgbox_header(MBX_INFO, (wchar_t *) IDS_4113, (wchar_t *) IDS_4117); }