Dmitry Timoshkov dmitry@sloboda.ru writes:
Since handler of WM_CLOSE in DefWindowProc calls DestroyWindow, which eventually sends WM_DESTROY, EDITSTATE gets destroyed before call to EDIT_UnlockBuffer in the end of processing of WM_CLOSE, therefore EDIT_UnlockBuffer gets confused.
This is not specific to WM_CLOSE, it can happen with other messages too; any time we transfer control back to the application the window can be destroyed. I think it would be better to either unlock the buffer before calling DefWindowProc, or make EDIT_UnlockBuffer cope with a destroyed window.