From 7a3cc69779ac2689340311f7b994b989c5b11e69 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 18 Mar 2016 07:22:26 +0000 Subject: [PATCH] parse.y: Fix for nth_ref_max * parse.y (parse_numvar): NTH_REF must be less than a half of INT_MAX, as it is left-shifted to be ORed with back-ref flag. [ruby-core:74444] [Bug#12192] [Fix GH-1296] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c34a0648f2..2dfa7d6c9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Mar 18 16:22:24 2016 Victor Nawothnig + + * parse.y (parse_numvar): NTH_REF must be less than a half of + INT_MAX, as it is left-shifted to be ORed with back-ref flag. + [ruby-core:74444] [Bug#12192] [Fix GH-1296] + Fri Mar 18 12:25:30 2016 Nobuyoshi Nakada * gc.c (tick): fix missing close parenthesis. [Fix GH-1291] diff --git a/parse.y b/parse.y index dbdcb95127..4303bea5b2 100644 --- a/parse.y +++ b/parse.y @@ -7833,7 +7833,7 @@ parse_numvar(struct parser_params *parser) int overflow; unsigned long n = ruby_scan_digits(tok()+1, toklen()-1, 10, &len, &overflow); const unsigned long nth_ref_max = - (FIXNUM_MAX / 2 < INT_MAX) ? FIXNUM_MAX / 2 : INT_MAX; + ((FIXNUM_MAX < INT_MAX) ? FIXNUM_MAX : INT_MAX) >> 1; /* NTH_REF is left-shifted to be ORed with back-ref flag and * turned into a Fixnum, in compile.c */