Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1143,6 +1143,10 @@ public IRubyObject op_plus(ThreadContext context, IRubyObject arg) {
public IRubyObject op_plus19(ThreadContext context, IRubyObject arg) {
RubyString str = arg.convertToString();
Encoding enc = checkEncoding(str);
long len = (long) value.getRealSize() + str.value.getRealSize();

// we limit to int because ByteBuffer can only allocate int sizes
if (len > Integer.MAX_VALUE) throw context.runtime.newArgumentError("argument too big");
RubyString resultStr = newStringNoCopy(context.runtime, StringSupport.addByteLists(value, str.value),
enc, CodeRangeSupport.codeRangeAnd(getCodeRange(), str.getCodeRange()));
resultStr.infectBy(flags | str.flags);

0 comments on commit 800dee2

Please sign in to comment.