Fixed all instances of the usage of wcstombs to use a sizeof() of whatever the destination is instead of the source size.

This commit is contained in:
OBattler
2017-07-20 11:32:41 +02:00
parent b18f16c4bc
commit 3e195b74d0
5 changed files with 11 additions and 10 deletions

View File

@@ -198,7 +198,7 @@ int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)
}
if (r)
{
wcstombs(openfilestring, wopenfilestring, 520);
wcstombs(openfilestring, wopenfilestring, sizeof(openfilestring));
pclog("File dialog return true\n");
return 0;
}

View File

@@ -663,7 +663,7 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
h = GetDlgItem(hdlg, IDC_MEMTEXT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, (wcslen(lptsTemp) * 2) + 2);
wcstombs(stransi, lptsTemp, sizeof(stransi));
sscanf(stransi, "%i", &temp_mem_size);
temp_mem_size &= ~(models[temp_model].ram_granularity - 1);
if (temp_mem_size < models[temp_model].min_ram)
@@ -765,7 +765,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, (wcslen(lptsTemp) * 2) + 2);
wcstombs(stransi, lptsTemp, sizeof(stransi));
gfx = video_card_getid(stransi);
h = GetDlgItem(hdlg, IDC_CONFIGURE_VID);
@@ -792,7 +792,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, (wcslen(lptsTemp) * 2) + 2);
wcstombs(stransi, lptsTemp, sizeof(stransi));
gfx = video_card_getid(stransi);
temp_gfxcard = video_new_to_old(gfx);
@@ -828,7 +828,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, (wcslen(lptsTemp) * 2) + 2);
wcstombs(stransi, lptsTemp, sizeof(stransi));
deviceconfig_open(hdlg, (void *)video_card_getdevice(video_card_getid(stransi)));
free(stransi);
@@ -843,7 +843,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, (wcslen(lptsTemp) * 2) + 2);
wcstombs(stransi, lptsTemp, sizeof(stransi));
temp_gfxcard = video_new_to_old(video_card_getid(stransi));
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO_SPEED);
@@ -2436,7 +2436,7 @@ static void get_edit_box_contents(HWND hdlg, int id, uint64_t *val)
h = GetDlgItem(hdlg, id);
SendMessage(h, WM_GETTEXT, 255, (LPARAM) szText);
wcstombs(stransi, szText, (wcslen(szText) * 2) + 2);
wcstombs(stransi, szText, sizeof(stransi));
sscanf(stransi, "%" PRIu64, val);
}