PATCH: Edit control (controls\edit.c)

Sander van Leeuwen sandervl at xs4all.nl
Fri Feb 7 05:31:52 CST 2003


Changes:
1) Fixed incorrect undo buffer size (previous code caused heap corruption when using backspace many times)
2) Always kill timer when left mouse button is released and in captured state
    (application can release capture which leaves the control is a bad state)

Authors: (Odin)
1) Dietrich Teickner <Dietrich_Teickner at t-online.de>
2) Sander van Leeuwen <sandervl at xs4all.nl>

License: X11/LGPL

@@ -1747,7 +1747,7 @@
 
 	alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
 	if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
-		es->undo_buffer_size = alloc_size/sizeof(WCHAR);
+		es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
 		return TRUE;
 	}
 	else

@@ -4216,9 +4216,9 @@
  */
 static LRESULT EDIT_WM_LButtonUp(EDITSTATE *es)
 {
-	if (es->bCaptureState && GetCapture() == es->hwndSelf) {
-		KillTimer(es->hwndSelf, 0);
-		ReleaseCapture();
+	if (es->bCaptureState) {
+		KillTimer(es->hwndSelf, 0);
+		if(GetCapture() == es->hwndSelf) ReleaseCapture();
 	}
 	es->bCaptureState = FALSE;
 	return 0;





More information about the wine-patches mailing list