diff --git a/Changes b/Changes index e6501a7b1..f597b2e19 100644 --- a/Changes +++ b/Changes @@ -926,3 +926,4 @@ seen. gmtime warning still there - Recoded the way the editor menu works (hopefully this is much better?) - Added the ability to create new files via the win32 editor +- Fixed a win32 editor bug caused by me being drunk or something :P diff --git a/src/win32/Win32GUI.c b/src/win32/Win32GUI.c index 20f84ea3b..0f6786ada 100644 --- a/src/win32/Win32GUI.c +++ b/src/win32/Win32GUI.c @@ -215,15 +215,22 @@ void WipeColors() { DWORD CALLBACK BufferIt(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { char *buf2; static long size = 0; + if (!RTFBuf) + size = 0; + buf2 = MyMalloc(size+cb+1); + if (RTFBuf) memcpy(buf2,RTFBuf,size); - else - size = 0; + memcpy(buf2+size,pbBuff,cb); + size += cb; - MyFree(RTFBuf); + if (RTFBuf) + MyFree(RTFBuf); + RTFBuf = buf2; + pcb = &cb; return 0; } @@ -1087,8 +1094,7 @@ LRESULT CALLBACK FromFileDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar else break; } - - + fd = open(file, _O_TRUNC|_O_CREAT|_O_WRONLY|_O_BINARY,_S_IWRITE); edit.dwCookie = 0; edit.pfnCallback = BufferIt; @@ -1096,6 +1102,7 @@ LRESULT CALLBACK FromFileDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar SendMessage(GetDlgItem(hDlg, IDC_TEXT), EM_STREAMOUT, (WPARAM)SF_RTF|SFF_PLAINRTF, (LPARAM)&edit); RTFToIRC(fd, RTFBuf, strlen(RTFBuf)); free(RTFBuf); + RTFBuf = NULL; EndDialog(hDlg, TRUE); } hWnd = GetDlgItem(hDlg, IDC_TEXT);