aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-06-30 20:06:04 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-07-20 18:52:16 +0300
commit3bf3d3722764771df32233b0443035033b8153f8 (patch)
tree08f08ed2ae130cbe8bd7e0a8e2c9e52895c973a8 /monsterwm.c
parentd6d3de3788a4e5bab4e751fedcd241f29cbf4bb8 (diff)
rework move_up and move_down functions - should check for existance of at least two clients
bugfix: this is a null dereference bug that would segfault monsterwm if one tried to move a client up or down while there were no clients this was introduced by mistake when the prev_client function was introduced; now prevclient see commit: 0a900d49
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/monsterwm.c b/monsterwm.c
index 0c55e0d..31d41f3 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -575,9 +575,9 @@ void monocle(int hh, int cy) {
/* move the current client, to current->next
* and current->next to current client's position */
void move_down(void) {
+ if (!curr || !head->next) return;
/* p is previous, c is current, n is next, if current is head n is last */
Client *p = prevclient(curr), *n = (curr->next) ? curr->next:head;
- if (!p) return;
/*
* if c is head, swapping with n should update head to n
* [c]->[n]->.. ==> [n]->[c]->..
@@ -612,9 +612,9 @@ void move_down(void) {
/* move the current client, to the previous from current and
* the previous from current to current client's position */
void move_up(void) {
+ if (!curr || !head->next) return;
/* p is previous from current or last if current is head */
Client *pp = NULL, *p = prevclient(curr);
- if (!p) return;
/* pp is previous from p, or null if current is head and thus p is last */
if (p->next) for (pp = head; pp && pp->next != p; pp = pp->next);
/*