Skip to content

Commit 8122da2

Browse files
committed
Avoid using exact math in Posix module ReadNode
1 parent 2cf7e46 commit 8122da2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,8 @@ public abstract static class ReadNode extends PythonFileNode {
12301230
Object readLong(@SuppressWarnings("unused") VirtualFrame frame, int fd, long requestedSize,
12311231
@Shared("profile") @Cached("createClassProfile()") ValueProfile channelClassProfile,
12321232
@Shared("readNode") @Cached ReadFromChannelNode readNode) {
1233-
int size;
1234-
try {
1235-
size = Math.toIntExact(requestedSize);
1236-
} catch (ArithmeticException e) {
1233+
int size = (int) requestedSize;
1234+
if (size != requestedSize) {
12371235
tooLargeProfile.enter();
12381236
size = ReadFromChannelNode.MAX_READ;
12391237
}

0 commit comments

Comments
 (0)