InvokeStatic: pass (nullptr, 0) when there are no args
Previously, the behavior depended on how the STL implemented a
std::array of zero length. libc++'s behavior changed in D80821 from a
non-null data() to a null data().
In InvokeInstance, vregs will always have at least the receiver, so
data() will never be null.
Bug: b/293402944
Test: treehugger
Change-Id: Ibd2c772baa14993b2fbdd2abdb6b58621dca0c5c
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 7353b14..e79e5a4 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -184,7 +184,11 @@
JValue result;
constexpr auto shorty = detail::MaterializeShorty<ReturnType, ArgType...>();
auto vregs = detail::MaterializeVRegs<ArgType...>(args...);
- Invoke(self, vregs.data(), sizeof(vregs), &result, shorty.data());
+ Invoke(self,
+ vregs.empty() ? nullptr : vregs.data(),
+ vregs.size() * sizeof(typename decltype(vregs)::value_type),
+ &result,
+ shorty.data());
return detail::ShortyTraits<ReturnType>::Get(result);
}
@@ -198,7 +202,11 @@
JValue result;
constexpr auto shorty = detail::MaterializeShorty<ReturnType, ArgType...>();
auto vregs = detail::MaterializeVRegs<'L', ArgType...>(receiver, args...);
- Invoke(self, vregs.data(), sizeof(vregs), &result, shorty.data());
+ Invoke(self,
+ vregs.data(),
+ vregs.size() * sizeof(typename decltype(vregs)::value_type),
+ &result,
+ shorty.data());
return detail::ShortyTraits<ReturnType>::Get(result);
}