diff options
author | Jeremy Evans <code@jeremyevans.net> | 2023-12-12 16:58:20 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2023-12-13 07:05:21 -0800 |
commit | 0d53dba7ce900387397610c060cfa24758fc806a (patch) | |
tree | 194209543de6a4a1212a21a9db225f96bab20fe9 /string.c | |
parent | c42e4a38e9839fe3380566727304f3fd75a6506a (diff) |
Make String#chomp! raise ArgumentError for 2+ arguments if string is empty
String#chomp! returned nil without checking the number of passed
arguments in this case.
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -9689,7 +9689,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) { VALUE rs; str_modifiable(str); - if (RSTRING_LEN(str) == 0) return Qnil; + if (RSTRING_LEN(str) == 0 && argc < 2) return Qnil; rs = chomp_rs(argc, argv); if (NIL_P(rs)) return Qnil; return rb_str_chomp_string(str, rs); |