Skip to content

Commit a587c6c

Browse files
authored
Merge pull request #3973 from LinuxForHealth/issue-3957-narrow-conv
issue #3957 avoid narrowing conversion flagged by CodeQL
2 parents 5430d33 + bcd8abc commit a587c6c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

fhir-persistence/src/main/java/org/linuxforhealth/fhir/persistence/util/InputOutputByteStream.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,18 @@ public int read(byte b[], int off, int len) throws IOException {
129129

130130
@Override
131131
public long skip(long n) {
132-
if (n < 0) {
132+
if (n <= 0) {
133133
return 0;
134134
}
135135

136136
// don't try to skip more than we have left
137-
long remaining = offset - posn;
137+
final int remaining = offset - posn;
138138
if (n > remaining) {
139139
n = remaining;
140140
}
141141

142-
posn += n;
142+
// it is safe to convert to int here because we have already checked the bound above
143+
posn += (int)n;
143144
return n;
144145
}
145146

0 commit comments

Comments
 (0)