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)
committerYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sat, 10 Apr 2010 02:02:01 +0000 (11:02 +0900)
Fixes segfault upon TERM=cons25.

usr.bin/window/ttgeneric.c

index 44bfe60..7de3845 100644 (file)
@@ -161,8 +161,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);
                        }
        }
@@ -173,8 +173,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);
                        }
        }