summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2020-09-28 17:35:27 -0400
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-30 00:31:59 +0900
commitf7bd9f075030e5fa876320c1624a80685a636e82 (patch)
treec51fdea056b14938e1dc73fd93c3fd99400c090c /numeric.c
parentcece71b46708d69c74583d48478ea4d0401bb746 (diff)
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
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3602
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index 387e46f29b..6d4eb86b1a 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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;
}