diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-11-15 16:53:51 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-11-16 01:26:23 +0900 |
commit | 4f2ac9e30035a7d48e7856007d72a55f110ba8e9 (patch) | |
tree | e5f29450222424b4fc0642f9bcc5c57d93bffa64 | |
parent | 54e903e0eb17c1d3d8b4c7655e4dc49dcb529599 (diff) | |
download | ruby-4f2ac9e30035a7d48e7856007d72a55f110ba8e9.tar.gz |
re.c: make MatchData#hash check the MatchData is already initialized
Make sure that the MatchData is already initialized by calling
match_check() first so as not to dereference NULL.
-rw-r--r-- | re.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -2948,8 +2948,10 @@ static VALUE match_hash(VALUE match) { const struct re_registers *regs; - st_index_t hashval = rb_hash_start(rb_str_hash(RMATCH(match)->str)); + st_index_t hashval; + match_check(match); + hashval = rb_hash_start(rb_str_hash(RMATCH(match)->str)); rb_hash_uint(hashval, reg_hash(RMATCH(match)->regexp)); regs = RMATCH_REGS(match); hashval = rb_hash_uint(hashval, regs->num_regs); |