From 984b8bea00b74d5c8ca97ae0037dc283d2f36610 Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Fri, 11 Aug 2017 12:04:44 +0200 Subject: [PATCH] Fix: Srcref could also be NULL. --- .../oracle/truffle/r/runtime/RSerialize.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java index 9d6cfd297e..00ed14aece 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java @@ -2744,18 +2744,20 @@ public class RSerialize { assert srcfile instanceof REnvironment; Source source = RSource.fromSrcfile((REnvironment) srcfile); - RList l = (RList) srcref; + RList blockSrcref = (RList) srcref; RSyntaxElement[] syntaxArguments = elem.getSyntaxArguments(); - assert syntaxArguments.length == l.getLength() - 1; - - for (int i = 0; i < l.getLength(); i++) { - Object dataAt = l.getDataAt(i); - assert dataAt instanceof RAbstractIntVector; - SourceSection ss = RSrcref.createSourceSection((RAbstractIntVector) dataAt, source); - if (i == 0) { - elem.setSourceSection(ss); - } else { - syntaxArguments[i - 1].setSourceSection(ss); + assert syntaxArguments.length == blockSrcref.getLength() - 1; + + for (int i = 0; i < blockSrcref.getLength(); i++) { + Object singleSrcref = blockSrcref.getDataAt(i); + // could also be NULL + if (singleSrcref instanceof RAbstractIntVector) { + SourceSection ss = RSrcref.createSourceSection((RAbstractIntVector) singleSrcref, source); + if (i == 0) { + elem.setSourceSection(ss); + } else { + syntaxArguments[i - 1].setSourceSection(ss); + } } } } catch (NoSuchFileException e) { -- GitLab