window(1): Perform NULL check before strcmp() rather than after.
authorYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sat, 10 Apr 2010 01:47:16 +0000 (10:47 +0900)
committerSascha Wildner <saw@online.de>
Wed, 21 Apr 2010 22:46:46 +0000 (00:46 +0200)
Fixes segfault upon TERM=cons25.

usr.bin/window/ttgeneric.c

index d2d6d5c..b8baa83 100644 (file)
@@ -169,8 +169,8 @@ gen_setmodes(int new)
                } else
                        if (gen_SE) {
                                ttxputs(gen_SE);
-                               if (!strcmp(gen_SE->ts_str, gen_UE->ts_str) &&
-                                   gen_UE && gen_US && new & WWM_UL)
+                               if (gen_UE && gen_US && new & WWM_UL &&
+                                   !strcmp(gen_SE->ts_str, gen_UE->ts_str))
                                        ttxputs(gen_US);
                        }
        }
@@ -181,8 +181,8 @@ gen_setmodes(int new)
                } else
                        if (gen_UE) {
                                ttxputs(gen_UE);
-                               if (!strcmp(gen_UE->ts_str, gen_SE->ts_str) &&
-                                   gen_SE && gen_SO && new & WWM_REV)
+                               if (gen_SE && gen_SO && new & WWM_REV &&
+                                   !strcmp(gen_UE->ts_str, gen_SE->ts_str))
                                        ttxputs(gen_SO);
                        }
        }