diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-26 06:13:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-26 06:13:15 +0000 |
commit | 993f22cb1bba82be52e08e7132af003ae432163e (patch) | |
tree | a010dc21a323f496e16e9a2f7fe208c6ac1d0b97 /ext/json/parser/parser.rl | |
parent | ed316bcfad804c272c64fe70d1a360b0a8226bef (diff) | |
download | ruby-993f22cb1bba82be52e08e7132af003ae432163e.tar.gz |
parser.rl: check before use
* ext/json/parser/parser.rl (unescape_unicode): check if valid
before bit-or assignments.
reported by Denis Denisov <denji0k AT gmail.com>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/parser/parser.rl')
-rw-r--r-- | ext/json/parser/parser.rl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index 34e30f4868..3d7b5a65fb 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -26,16 +26,16 @@ static UTF32 unescape_unicode(const unsigned char *p) UTF32 result = 0; b = digit_values[p[0]]; if (b < 0) return UNI_REPLACEMENT_CHAR; - result = (result << 4) | b; + result = (result << 4) | (unsigned char)b; b = digit_values[p[1]]; - result = (result << 4) | b; if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; b = digit_values[p[2]]; - result = (result << 4) | b; if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; b = digit_values[p[3]]; - result = (result << 4) | b; if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; return result; } @@ -883,7 +883,7 @@ static VALUE cParser_quirks_mode_p(VALUE self) } -void Init_parser() +void Init_parser(void) { rb_require("json/common"); mJSON = rb_define_module("JSON"); |