cother/iother Segfault patch

Rob Paisley <paisley-fBzVes0d2/ZWk0Htik3J/[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
As reported by "Gentooer" in the #ratpoison IRC channel, there is a bug in
:cother and :iother.  If are no windows and you issue either :cother, or
:iother ratpoison segfaults.  The following patch resolves this issue.

diff --git a/src/actions.c b/src/actions.c
index b9116dd..d7b64eb 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -5678,10 +5678,11 @@ cmd_iprev (int interactive, struct cmdarg **args)
 cmdret *
 cmd_cother (int interactive UNUSED, struct cmdarg **args UNUSED)
 {
-  rp_window *cur, *w;
+  rp_window *cur, *w = NULL;
 
   cur = current_window();
-  w = group_last_window_by_class (rp_current_group, cur->res_class);
+  if (cur)
+    w = group_last_window_by_class (rp_current_group, cur->res_class);
 
   if (!w)
     return cmdret_new (RET_FAILURE, "%s", MESSAGE_NO_OTHER_WINDOW);
@@ -5694,10 +5695,11 @@ cmd_cother (int interactive UNUSED, struct cmdarg **args UNUSED)
 cmdret *
 cmd_iother (int interactive UNUSED, struct cmdarg **args UNUSED)
 {
-  rp_window *cur, *w;
+  rp_window *cur, *w = NULL;
 
   cur = current_window();
-  w = group_last_window_by_class_complement (rp_current_group, cur->res_class);
+  if (cur)
+    w = group_last_window_by_class_complement (rp_current_group, cur->res_class);
 
   if (!w)
     return cmdret_new (RET_FAILURE, "%s", MESSAGE_NO_OTHER_WINDOW);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.