Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
spectrwm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cc956fe
)
Fix move/resize to bail if the window gets destroyed.
author
Reginald Kennedy
<rk@rejii.com>
Fri, 16 Nov 2012 17:03:58 +0000
(
01:03
+0800)
committer
Reginald Kennedy
<rk@rejii.com>
Fri, 16 Nov 2012 17:13:07 +0000
(
01:13
+0800)
spectrwm.c
patch
|
blob
|
history
diff --git
a/spectrwm.c
b/spectrwm.c
index
1378638
..
5f8cc81
100644
(file)
--- a/
spectrwm.c
+++ b/
spectrwm.c
@@
-5325,6
+5325,12
@@
resize(struct ws_win *win, union arg *args)
focus_flush();
focus_flush();
+ /* It's possible for win to have been freed during focus_flush(). */
+ if (validate_win(win)) {
+ DNPRINTF(SWM_D_EVENT, "move: invalid win.\n");
+ goto out;
+ }
+
switch (args->id) {
case SWM_ARG_ID_WIDTHSHRINK:
WIDTH(win) -= SWM_RESIZE_STEPS;
switch (args->id) {
case SWM_ARG_ID_WIDTHSHRINK:
WIDTH(win) -= SWM_RESIZE_STEPS;
@@
-5381,7
+5387,7
@@
resize(struct ws_win *win, union arg *args)
xcb_flush(conn);
resizing = 1;
xcb_flush(conn);
resizing = 1;
- while ((evt = xcb_wait_for_event(conn)) && resizing) {
+ while (resizing && (evt = xcb_wait_for_event(conn))) {
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
DNPRINTF(SWM_D_EVENT, "resize: BUTTON_RELEASE\n");
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
DNPRINTF(SWM_D_EVENT, "resize: BUTTON_RELEASE\n");
@@
-5444,6
+5450,12
@@
resize(struct ws_win *win, union arg *args)
break;
default:
event_handle(evt);
break;
default:
event_handle(evt);
+
+ /* It's possible for win to have been freed above. */
+ if (validate_win(win)) {
+ DNPRINTF(SWM_D_EVENT, "move: invalid win.\n");
+ goto out;
+ }
break;
}
free(evt);
break;
}
free(evt);
@@
-5453,7
+5465,7
@@
resize(struct ws_win *win, union arg *args)
xcb_flush(conn);
}
store_float_geom(win,r);
xcb_flush(conn);
}
store_float_geom(win,r);
-
+out:
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
free(xpr);
DNPRINTF(SWM_D_EVENT, "resize: done.\n");
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
free(xpr);
DNPRINTF(SWM_D_EVENT, "resize: done.\n");
@@
-5512,6
+5524,12
@@
move(struct ws_win *win, union arg *args)
focus_flush();
focus_flush();
+ /* It's possible for win to have been freed during focus_flush(). */
+ if (validate_win(win)) {
+ DNPRINTF(SWM_D_EVENT, "move: invalid win.\n");
+ goto out;
+ }
+
move_stp = 0;
switch (args->id) {
case SWM_ARG_ID_MOVELEFT:
move_stp = 0;
switch (args->id) {
case SWM_ARG_ID_MOVELEFT:
@@
-5554,7
+5572,7
@@
move(struct ws_win *win, union arg *args)
xcb_flush(conn);
moving = 1;
xcb_flush(conn);
moving = 1;
- while ((evt = xcb_wait_for_event(conn)) && moving) {
+ while (moving && (evt = xcb_wait_for_event(conn))) {
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
DNPRINTF(SWM_D_EVENT, "move: BUTTON_RELEASE\n");
switch (XCB_EVENT_RESPONSE_TYPE(evt)) {
case XCB_BUTTON_RELEASE:
DNPRINTF(SWM_D_EVENT, "move: BUTTON_RELEASE\n");
@@
-5576,6
+5594,12
@@
move(struct ws_win *win, union arg *args)
break;
default:
event_handle(evt);
break;
default:
event_handle(evt);
+
+ /* It's possible for win to have been freed above. */
+ if (validate_win(win)) {
+ DNPRINTF(SWM_D_EVENT, "move: invalid win.\n");
+ goto out;
+ }
break;
}
free(evt);
break;
}
free(evt);
@@
-5585,6
+5609,7
@@
move(struct ws_win *win, union arg *args)
xcb_flush(conn);
}
store_float_geom(win, r);
xcb_flush(conn);
}
store_float_geom(win, r);
+out:
free(qpr);
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
DNPRINTF(SWM_D_EVENT, "move: done.\n");
free(qpr);
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
DNPRINTF(SWM_D_EVENT, "move: done.\n");