summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-02-18 00:30:07 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-02-18 00:30:07 +0900
commit800d99298718f3ab5e14d8e4c27138d5d4776dfa (patch)
treeed6bf8f24b90dbad2c360cb2352df73eec43c114
parent57b7f6b6198b54abe822b521e4026fc3992f2a25 (diff)
parent69bc004e089afd0179b9e5428731d1c1ece8c452 (diff)
downloadmruby-800d99298718f3ab5e14d8e4c27138d5d4776dfa.tar.gz
mruby-800d99298718f3ab5e14d8e4c27138d5d4776dfa.zip
Merge pull request #1717 from cremno/iv_size-t-null
iv_size (non-seglist): return 0 if t is NULL
-rw-r--r--src/variable.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/variable.c b/src/variable.c
index 3dc562a5e..957383ad2 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -369,10 +369,12 @@ iv_foreach(mrb_state *mrb, iv_tbl *t, iv_foreach_func *func, void *p)
static size_t
iv_size(mrb_state *mrb, iv_tbl *t)
{
- khash_t(iv) *h = &t->h;
+ khash_t(iv) *h;
- if (!h) return 0;
- return kh_size(h);
+ if (t && (h = &t->h)) {
+ return kh_size(h);
+ }
+ return 0;
}
static iv_tbl*