diff --git a/desmume/src/windows/IORegView.c b/desmume/src/windows/IORegView.c index 7a7e79b99..31acf81bb 100644 --- a/desmume/src/windows/IORegView.c +++ b/desmume/src/windows/IORegView.c @@ -32,7 +32,6 @@ LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) HDC hdc; PAINTSTRUCT ps; TCHAR text[80]; -// NDS_header * header = nds.getROMHeader(); hdc = BeginPaint(hwnd, &ps); @@ -73,7 +72,8 @@ BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return 1; case WM_CLOSE : CWindow_RemoveFromRefreshList(win); - free(win); + if (win) + free(win); EndDialog(hwnd, 0); return 1; case WM_PAINT: @@ -84,7 +84,8 @@ BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { case IDC_FERMER : CWindow_RemoveFromRefreshList(win); - free(win); + if (win) + free(win); EndDialog(hwnd, 0); return 1; } diff --git a/desmume/src/windows/main.c b/desmume/src/windows/main.c index 2ffbf7969..950894e2e 100644 --- a/desmume/src/windows/main.c +++ b/desmume/src/windows/main.c @@ -778,10 +778,16 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; case IDM_IOREG: { - cwindow_struct IoregView; + cwindow_struct *IoregView; - if (CWindow_Init2(&IoregView, hAppInst, HWND_DESKTOP, "IO REG VIEW", IDD_IO_REG, IoregView_Proc) == 0) - CWindow_Show(&IoregView); + if ((IoregView = malloc(sizeof(cwindow_struct))) == NULL) + return 0; + + if (CWindow_Init2(IoregView, hAppInst, HWND_DESKTOP, "IO REG VIEW", IDD_IO_REG, IoregView_Proc) == 0) + { + CWindow_AddToRefreshList(IoregView); + CWindow_Show(IoregView); + } } return 0; case IDM_QUIT: