diff options
| author | mattn <[email protected]> | 2012-04-26 11:29:30 +0900 |
|---|---|---|
| committer | mattn <[email protected]> | 2012-04-26 11:29:30 +0900 |
| commit | 45b36954df8bc46d16fadf17e0124f9719207a50 (patch) | |
| tree | 6a9cddca73bc07581664e2368a45fe6395ea0310 /src/variable.c | |
| parent | 0486c48b1aec2509076b6c2cc03ccc826d802c7d (diff) | |
| download | mruby-45b36954df8bc46d16fadf17e0124f9719207a50.tar.gz mruby-45b36954df8bc46d16fadf17e0124f9719207a50.zip | |
fix #56
Diffstat (limited to 'src/variable.c')
| -rw-r--r-- | src/variable.c | 8 |
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] = '$'; |
