aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-11-15 16:53:51 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-11-16 01:26:23 +0900
commit4f2ac9e30035a7d48e7856007d72a55f110ba8e9 (patch)
treee5f29450222424b4fc0642f9bcc5c57d93bffa64
parent54e903e0eb17c1d3d8b4c7655e4dc49dcb529599 (diff)
downloadruby-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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/re.c b/re.c
index 0536aa6d8e..6574d9fcdf 100644
--- a/re.c
+++ b/re.c
@@ -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);