Skip to content

Commit 7ed89b5

Browse files
committed
Fix null values for timespec long[]s
1 parent ea00209 commit 7ed89b5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,13 +1021,7 @@ public void utimensat(int dirFd, Object pathname, long[] timespec, boolean follo
10211021
@Shared("invoke") @Cached InvokeNativeFunction invokeNode) throws PosixException {
10221022
assert PosixConstants.HAVE_UTIMENSAT.value;
10231023
assert timespec == null || timespec.length == 4;
1024-
Object timespecArg;
1025-
if (timespec == null) {
1026-
timespecArg = PNone.NO_VALUE;
1027-
} else {
1028-
timespecArg = timespec;
1029-
}
1030-
int ret = invokeNode.callInt(this, PosixNativeFunction.call_utimensat, dirFd, pathToCString(pathname), timespecArg, followSymlinks ? 1 : 0);
1024+
int ret = invokeNode.callInt(this, PosixNativeFunction.call_utimensat, dirFd, pathToCString(pathname), wrap(timespec), followSymlinks ? 1 : 0);
10311025
if (ret != 0) {
10321026
throw newPosixException(invokeNode, getErrno(invokeNode));
10331027
}
@@ -1038,7 +1032,7 @@ public void futimens(int fd, long[] timespec,
10381032
@Shared("invoke") @Cached InvokeNativeFunction invokeNode) throws PosixException {
10391033
assert PosixConstants.HAVE_FUTIMENS.value;
10401034
assert timespec == null || timespec.length == 4;
1041-
int ret = invokeNode.callInt(this, PosixNativeFunction.call_futimens, fd, timespec);
1035+
int ret = invokeNode.callInt(this, PosixNativeFunction.call_futimens, fd, wrap(timespec));
10421036
if (ret != 0) {
10431037
throw newPosixException(invokeNode, getErrno(invokeNode));
10441038
}
@@ -2672,6 +2666,14 @@ private PosixException newPosixException(InvokeNativeFunction invokeNode, int er
26722666
throw new PosixException(errno, strerror(errno, invokeNode, TruffleString.FromByteArrayNode.getUncached(), TruffleString.SwitchEncodingNode.getUncached()));
26732667
}
26742668

2669+
private Object wrap(long[] value) {
2670+
if (value == null) {
2671+
return PNone.NO_VALUE;
2672+
} else {
2673+
return value;
2674+
}
2675+
}
2676+
26752677
private Object wrap(Timeval[] timeval) {
26762678
if (timeval == null) {
26772679
return PNone.NO_VALUE;

0 commit comments

Comments
 (0)