summaryrefslogtreecommitdiffstats
path: root/runtime/jdwp
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-09-15 11:27:27 +0200
committerSebastien Hertz <shertz@google.com>2014-09-17 11:52:24 +0200
commitb0b0b496125c16620e99ea4e4a05693c281eccf1 (patch)
treea73507873a28411f843b98701bcd0535d1dc361a /runtime/jdwp
parent97ca64b01e14de77ba14067b26069405d0dba0bf (diff)
downloadart-b0b0b496125c16620e99ea4e4a05693c281eccf1.zip
art-b0b0b496125c16620e99ea4e4a05693c281eccf1.tar.gz
art-b0b0b496125c16620e99ea4e4a05693c281eccf1.tar.bz2
Avoid crash in StringReference.Value JDWP command
Checks for null or invalid object id. Also checks whether the corresponding object is a java.lang.String. Bug: 17492221 Bug: 15005460 (cherry picked from commit 29259fa6b0514866d2d4bf57d58c1557b26abbb7) Change-Id: I52673bdef6912a4cccf5a6eeecb6e1e817b9dd6b
Diffstat (limited to 'runtime/jdwp')
-rw-r--r--runtime/jdwp/jdwp_handler.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc
index 8560cb5..e0a83f6 100644
--- a/runtime/jdwp/jdwp_handler.cc
+++ b/runtime/jdwp/jdwp_handler.cc
@@ -151,7 +151,12 @@ static JdwpError FinishInvoke(JdwpState*, Request* request, ExpandBuf* pReply,
/* show detailed debug output */
if (resultTag == JT_STRING && exceptObjId == 0) {
if (resultValue != 0) {
- VLOG(jdwp) << " string '" << Dbg::StringToUtf8(resultValue) << "'";
+ if (VLOG_IS_ON(jdwp)) {
+ std::string result_string;
+ JDWP::JdwpError error = Dbg::StringToUtf8(resultValue, &result_string);
+ CHECK_EQ(error, JDWP::ERR_NONE);
+ VLOG(jdwp) << " string '" << result_string << "'";
+ }
} else {
VLOG(jdwp) << " string (null)";
}
@@ -919,7 +924,11 @@ static JdwpError OR_ReferringObjects(JdwpState*, Request* request, ExpandBuf* re
static JdwpError SR_Value(JdwpState*, Request* request, ExpandBuf* pReply)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
ObjectId stringObject = request->ReadObjectId();
- std::string str(Dbg::StringToUtf8(stringObject));
+ std::string str;
+ JDWP::JdwpError error = Dbg::StringToUtf8(stringObject, &str);
+ if (error != JDWP::ERR_NONE) {
+ return error;
+ }
VLOG(jdwp) << StringPrintf(" --> %s", PrintableString(str.c_str()).c_str());