Skip to content

Commit 2fe2870

Browse files
committed
Do never return 'null' in 'getwd' / 'setwd'.
1 parent f8fa092 commit 2fe2870

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Getwd.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
3131
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
3232
import com.oracle.truffle.r.runtime.data.RDataFactory;
33+
import com.oracle.truffle.r.runtime.data.RNull;
3334
import com.oracle.truffle.r.runtime.ffi.BaseRFFI;
3435
import com.oracle.truffle.r.runtime.ffi.RFFIFactory;
3536

@@ -42,6 +43,9 @@ public abstract class Getwd extends RBuiltinNode.Arg0 {
4243
@TruffleBoundary
4344
protected Object getwd() {
4445
String result = getwdNode.execute();
45-
return RDataFactory.createStringVector(result);
46+
if (result != null) {
47+
return RDataFactory.createStringVector(result);
48+
}
49+
return RNull.instance;
4650
}
4751
}

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Setwd.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
3535
import com.oracle.truffle.r.runtime.RError;
3636
import com.oracle.truffle.r.runtime.Utils;
3737
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
38+
import com.oracle.truffle.r.runtime.data.RNull;
3839
import com.oracle.truffle.r.runtime.ffi.BaseRFFI;
3940
import com.oracle.truffle.r.runtime.ffi.RFFIFactory;
4041

@@ -60,7 +61,7 @@ protected Object setwd(String path) {
6061
} else {
6162
String nwdAbs = getwdNode.execute();
6263
Utils.updateCurwd(nwdAbs);
63-
return owd;
64+
return owd != null ? owd : RNull.instance;
6465
}
6566
}
6667
}

0 commit comments

Comments
 (0)