Skip to content

Commit c21d33d

Browse files
Copilotpjfanning
andcommitted
Fix parameter validation order in UTF32Reader to catch negative length
Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
1 parent e6bb0f6 commit c21d33d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/tools/jackson/core/io/UTF32Reader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ public int read() throws IOException {
114114
public int read(char[] cbuf, int start, int len) throws IOException
115115
{
116116
Objects.requireNonNull(cbuf, "cbuf");
117-
// Already EOF?
118-
if (_buffer == null) { return -1; }
119-
if (len < 1) { return len; }
120117
// Let's then ensure there's enough room...
121118
if (start < 0 || len < 0 || start > (cbuf.length - len)) {
122119
reportBounds(cbuf, start, len);
123120
}
121+
// Already EOF?
122+
if (_buffer == null) { return -1; }
123+
if (len < 1) { return len; }
124124

125125
int outPtr = start;
126126
final int outEnd = len+start;

0 commit comments

Comments
 (0)