changeset 3259:5711545ff998

Fixed segfault when panel config is omitted
author unexist
date Fri, 22 Dec 2017 08:59:01 +0100
parents 7745d5f9a9d6
children b5eaf6f8415d
files src/subtle/ruby.c
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtle/ruby.c	Thu Dec 21 15:58:10 2017 +0100
+++ b/src/subtle/ruby.c	Fri Dec 22 08:59:01 2017 +0100
@@ -1032,19 +1032,22 @@
   int i;
 
   /* Iterate over config array */
-  for(i = 0; i < (int)RARRAY_LEN(config); i += 2)
+  if(!NIL_P(config))
     {
-      int idx      = FIX2INT(rb_ary_entry(config, i));
-      VALUE panels = rb_ary_entry(config, i + 1);
-
-      /* Sanity check */
-      SubScreen *s = SCREEN(subArrayGet(subtle->screens, (idx - 1)));
-
-      if(s)
+      for(i = 0; i < (int)RARRAY_LEN(config); i += 2)
         {
-          if(!s->panels) s->panels = subArrayNew();
-
-          RubyEvalPanel(panels, flag, s);
+          int idx      = FIX2INT(rb_ary_entry(config, i));
+          VALUE panels = rb_ary_entry(config, i + 1);
+
+          /* Sanity check */
+          SubScreen *s = SCREEN(subArrayGet(subtle->screens, (idx - 1)));
+
+          if(s)
+            {
+              if(!s->panels) s->panels = subArrayNew();
+
+              RubyEvalPanel(panels, flag, s);
+            }
         }
     }
 } /* }}} */