Skip to content
Snippets Groups Projects
Commit e45ada95 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

[GR-2738] Fix length check in RRuntime.parseInt, fix assertion in BinaryMapNode.

parents f3f544be 2c2de34d
No related branches found
No related tags found
No related merge requests found
......@@ -496,7 +496,7 @@ abstract class VectorMapBinaryInternalNode extends RBaseNode {
@Cached("createCountingProfile()") LoopConditionProfile leftProfile,
@Cached("createCountingProfile()") LoopConditionProfile rightProfile,
@Cached("createBinaryProfile()") ConditionProfile smallRemainderProfile) {
assert result != right;
assert result != right || rightLength == leftLength;
leftProfile.profileCounted(leftLength);
rightProfile.profileCounted(rightLength);
while (leftProfile.inject(leftIter.getIndex() + 1 < leftLength)) {
......@@ -527,7 +527,7 @@ abstract class VectorMapBinaryInternalNode extends RBaseNode {
@Cached("createCountingProfile()") LoopConditionProfile leftProfile,
@Cached("createCountingProfile()") LoopConditionProfile rightProfile,
@Cached("createBinaryProfile()") ConditionProfile smallRemainderProfile) {
assert result != left;
assert result != left || rightLength == leftLength;
leftProfile.profileCounted(leftLength);
rightProfile.profileCounted(rightLength);
while (rightProfile.inject(rightIter.getIndex() + 1 < rightLength)) {
......
......@@ -361,6 +361,9 @@ public class RRuntime {
@TruffleBoundary
public static int parseInt(String s) {
int length = s.length();
if (length == 0) {
throw new NumberFormatException();
}
long value = 0;
if (s.charAt(0) == '-') {
if (length == 1) {
......@@ -379,9 +382,6 @@ public class RRuntime {
}
return (int) -value;
} else {
if (length == 0) {
throw new NumberFormatException();
}
int pos = 0;
while (pos < length) {
char ch = s.charAt(pos++);
......@@ -400,6 +400,9 @@ public class RRuntime {
@TruffleBoundary
public static int parseIntWithNA(String s) {
int length = s.length();
if (length == 0) {
return INT_NA;
}
long value = 0;
if (s.charAt(0) == '-') {
if (length == 1) {
......@@ -418,9 +421,6 @@ public class RRuntime {
}
return (int) -value;
} else {
if (length == 0) {
return INT_NA;
}
int pos = 0;
while (pos < length) {
char ch = s.charAt(pos++);
......
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