JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Add unusual paranoia to make sure we crash and dump core if we see any
authorMarco Peereboom <marco@conformal.com>
Thu, 8 Oct 2009 19:21:24 +0000 (19:21 +0000)
committerMarco Peereboom <marco@conformal.com>
Thu, 8 Oct 2009 19:21:24 +0000 (19:21 +0000)
sign of trouble in switchws.

Roll back version to 0.9.11 for snapshot.

scrotwm.c

index bc05a22..ad295f7 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -52,7 +52,7 @@
 
 static const char      *cvstag = "$scrotwm$";
 
 
 static const char      *cvstag = "$scrotwm$";
 
-#define        SWM_VERSION     "1.0"
+#define        SWM_VERSION     "0.9.11"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -1342,8 +1342,14 @@ switchws(struct swm_region *r, union arg *args)
        struct ws_win           *win, *winfocus = NULL, *parent = NULL;
        struct workspace        *new_ws, *old_ws;
 
        struct ws_win           *win, *winfocus = NULL, *parent = NULL;
        struct workspace        *new_ws, *old_ws;
 
-       if (!(r && r->s))
-               return;
+       if (!(r && r->s)) {
+               fprintf(stderr, "r && r->s failed\n");
+               abort();
+       }
+       if (wsid < 0 || wsid > SWM_WS_MAX) {
+               fprintf(stderr, "illegal wsid\n");
+               abort();
+       }
 
        this_r = r;
        old_ws = this_r->ws;
 
        this_r = r;
        old_ws = this_r->ws;
@@ -1353,7 +1359,12 @@ switchws(struct swm_region *r, union arg *args)
            "%d -> %d\n", r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r),
            old_ws->idx, wsid);
 
            "%d -> %d\n", r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r),
            old_ws->idx, wsid);
 
-       if (new_ws == NULL || old_ws == NULL || new_ws == old_ws)
+       if (new_ws == NULL || old_ws == NULL) {
+               fprintf(stderr, "new_ws = %p old_ws = %p\n", new_ws, old_ws);
+               abort();
+       }
+
+       if (new_ws == old_ws)
                return;
 
        /* get focus window */
                return;
 
        /* get focus window */
@@ -1662,6 +1673,10 @@ stack(void) {
                            "(screen %d, region %d)\n", r->ws->idx, i, j++);
 
                        /* start with screen geometry, adjust for bar */
                            "(screen %d, region %d)\n", r->ws->idx, i, j++);
 
                        /* start with screen geometry, adjust for bar */
+                       if (r == NULL) {
+                               fprintf(stderr, "illegal r\n");
+                               abort();
+                       }
                        g = r->g;
                        g.w -= 2;
                        g.h -= 2;
                        g = r->g;
                        g.w -= 2;
                        g.h -= 2;
@@ -1669,8 +1684,19 @@ stack(void) {
                                g.y += bar_height;
                                g.h -= bar_height;
                        }
                                g.y += bar_height;
                                g.h -= bar_height;
                        }
-
+                       if (r->ws == NULL) {
+                               fprintf(stderr, "illegal ws\n");
+                               abort();
+                       }
+                       if (r->ws->cur_layout == NULL) {
+                               fprintf(stderr, "illegal cur_layout\n");
+                               abort();
+                       }
                        r->ws->restack = 0;
                        r->ws->restack = 0;
+                       if (r->ws->cur_layout->l_stack == NULL) {
+                               fprintf(stderr, "illegal l_stack\n");
+                               abort();
+                       }
                        r->ws->cur_layout->l_stack(r->ws, &g);
                }
        }
                        r->ws->cur_layout->l_stack(r->ws, &g);
                }
        }