Skip to content

Commit

Permalink
Limit incoming buffer to avoid overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 20, 2023
1 parent 737b71a commit c726bcf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyIOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ public void resize(ThreadContext context, int size) {
// no special behavior for isInternal=true since we do not control the internals of ByteBuffers.

ByteBuffer newBase = this.base.isDirect() ? ByteBuffer.allocateDirect(size) : ByteBuffer.allocate(size);
this.base.limit(Math.min(size, this.base.capacity()));
newBase.put(this.base);
this.base.clear();
newBase.clear();

this.base = newBase;
Expand Down

0 comments on commit c726bcf

Please sign in to comment.