diff options
author | Peter Zhu <peter@peterzhu.ca> | 2020-09-28 17:35:27 -0400 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-09-30 00:31:59 +0900 |
commit | f7bd9f075030e5fa876320c1624a80685a636e82 (patch) | |
tree | c51fdea056b14938e1dc73fd93c3fd99400c090c /numeric.c | |
parent | cece71b46708d69c74583d48478ea4d0401bb746 (diff) | |
download | ruby-f7bd9f075030e5fa876320c1624a80685a636e82.tar.gz |
Fix unsigned int overflow in error message for chr
The error message has an integer overflow because it treats an unsigned int as a signed int.
Before:
```
> 3_000_000_000.chr
-1294967296 out of char range (RangeError)
```
After:
```
> 3_000_000_000.chr
3000000000 out of char range (RangeError)
```
Redmine ticket: https://bugs.ruby-lang.org/issues/17186
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -3417,7 +3417,7 @@ int_chr(int argc, VALUE *argv, VALUE num) if (0xff < i) { enc = rb_default_internal_encoding(); if (!enc) { - rb_raise(rb_eRangeError, "%d out of char range", i); + rb_raise(rb_eRangeError, "%u out of char range", i); } goto decode; } |