Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against read producing a too-long String
Badly-behaved #read implementations may produce String output that exceeds the requested length, as theorized in jruby#8391. If this code blindly attempts to copy all bytes from such a String, it may cause an ArrayIndexOutOfBoundsError when it writes over the end of the passed-in buffer. This change guards against such #read implementations by raising a hard error; we do not maintain a buffer in this class, so we can't just hold onto the extra bytes, and we don't want to just silently discard them. A hard error will let a user of this class find bad #read implementations more quickly and fix the real problem. Fixes bug #1 from jruby#8391.
- Loading branch information