summaryrefslogtreecommitdiffstats
path: root/test/082-inline-execute
diff options
context:
space:
mode:
authorAlexei Zavjalov <alexei.zavjalov@intel.com>2014-04-17 01:55:43 +0700
committerAlexei Zavjalov <alexei.zavjalov@intel.com>2014-04-17 17:06:39 +0700
commita1758d83e298c9ee31848bcae07c2a35f6efd618 (patch)
treea8444d43cbc686240e700daf594527a28bf63797 /test/082-inline-execute
parentb94fae66dac14be955c68028447cdad84ee22bf9 (diff)
downloadart-a1758d83e298c9ee31848bcae07c2a35f6efd618.tar.gz
art-a1758d83e298c9ee31848bcae07c2a35f6efd618.tar.bz2
art-a1758d83e298c9ee31848bcae07c2a35f6efd618.zip
String.IndexOf method handles negative start index value in incorrect way
The standard implementation of String.IndexOf converts the negative value of the start index to 0 and searching will start from the beginning of the string. But current implementation may start searching from the incorrect memory offset, that can lead to sigsegv or return incorrect result. This patch adds the handler for cases when fromIndex is negative. Change-Id: I3ac86290712789559eaf5e46bef0006872395bfa Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>
Diffstat (limited to 'test/082-inline-execute')
-rw-r--r--test/082-inline-execute/src/Main.java2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java
index 86a03abca2..55ecf6922b 100644
--- a/test/082-inline-execute/src/Main.java
+++ b/test/082-inline-execute/src/Main.java
@@ -97,6 +97,7 @@ public class Main {
}
static int start;
+ private static int[] negIndex = { -100000 };
public static void test_String_indexOf() {
String str0 = "";
String str1 = "/";
@@ -125,6 +126,7 @@ public class Main {
Assert.assertEquals(str0.indexOf('a',0), -1);
Assert.assertEquals(str0.indexOf('a',-1), -1);
Assert.assertEquals(str1.indexOf('/',++start), -1);
+ Assert.assertEquals(str1.indexOf('a',negIndex[0]), -1);
Assert.assertEquals(str3.indexOf('a',0), 0);
Assert.assertEquals(str3.indexOf('a',1), -1);
Assert.assertEquals(str3.indexOf('a',1234), -1);