Fix read of uninitialized memory in InlineIndexOf
The are two flavors of IndexOf that we treat as an intrinsic: a
zero-based verion with 2 args and a 3-arg version that also takes
a start position. The same code is used for both, but Valgrind
reminded us that we shouldn't try loading a RegLocation for the
non-extent 3rd arg in the 2 argument version.
We got lucky in that the bug was benign - the generated code would
still be correct.
Change-Id: I0bc7798c8034d35007ffe6d6d62f9ceb91fc44fd
diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc
index dd3d466..2f017c8 100644
--- a/compiler/dex/quick/gen_invoke.cc
+++ b/compiler/dex/quick/gen_invoke.cc
@@ -1251,12 +1251,12 @@
RegLocation rl_obj = info->args[0];
RegLocation rl_char = info->args[1];
- RegLocation rl_start = info->args[2];
LoadValueDirectFixed(rl_obj, reg_ptr);
LoadValueDirectFixed(rl_char, reg_char);
if (zero_based) {
LoadConstant(reg_start, 0);
} else {
+ RegLocation rl_start = info->args[2]; // 3rd arg only present in III flavor of IndexOf.
LoadValueDirectFixed(rl_start, reg_start);
}
int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pIndexOf));