summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/variable.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/variable.c b/src/variable.c
index a9f04538b..7116155a7 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -347,9 +347,11 @@ mrb_f_global_variables(mrb_state *mrb, mrb_value self)
struct kh_iv *h = mrb->globals;
mrb_value ary = mrb_ary_new(mrb);
- for (i=0;i< kh_end(h);i++) {
- if (kh_exist(h, i)) {
- mrb_ary_push(mrb, ary, mrb_symbol_value(kh_key(h,i)));
+ if (h) {
+ for (i=0;i < kh_end(h);i++) {
+ if (kh_exist(h, i)) {
+ mrb_ary_push(mrb, ary, mrb_symbol_value(kh_key(h,i)));
+ }
}
}
buf[0] = '$';