Skip to content
Snippets Groups Projects
Commit bfc50e6c authored by Tomas Stupka's avatar Tomas Stupka
Browse files

fixed NPE in Parse.createSource()

parent e349f605
No related branches found
No related tags found
No related merge requests found
......@@ -174,7 +174,8 @@ public abstract class Parse extends RBuiltinNode {
private static Source createSource(Object srcFile, String coalescedLines) {
if (srcFile instanceof REnvironment) {
REnvironment srcFileEnv = (REnvironment) srcFile;
boolean isFile = RRuntime.fromLogical((byte) srcFileEnv.get("isFile"));
Object b = srcFileEnv.get("isFile");
boolean isFile = RRuntime.fromLogical(b != null ? (byte) b : 0);
if (isFile) {
// Might be a URL
String urlFileName = RRuntime.asString(srcFileEnv.get("filename"));
......
......@@ -4,7 +4,7 @@
* http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright (c) 2012-2014, Purdue University
* Copyright (c) 2013, 2016, Oracle and/or its affiliates
* Copyright (c) 2013, 2017, Oracle and/or its affiliates
*
* All rights reserved.
*/
......@@ -13,6 +13,7 @@ package com.oracle.truffle.r.test.builtins;
import org.junit.Test;
import com.oracle.truffle.r.test.TestBase;
import java.io.IOException;
// Checkstyle: stop line length check
......@@ -57,4 +58,10 @@ public class TestBuiltin_parse extends TestBase {
public void testArgumentsCasts() {
assertEval(".Internal(parse(stdin(), c(1,2), c('expr1', 'expr2'), '?', '<weird-text', 'unknown'))");
}
@Test
public void testSrcfile() throws IOException {
assertEval("parse(text='', srcfile=srcfile(system.file('testfile')))");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment