More JDWP robustness.
We pass a lot more JDWP tests with this (fewer total failures than dalvik,
because although dalvik implements more requests, it assumes that the debuggers
only send it valid input).
I've also added some of the missing constants (there are tests of modifier 12,
SourceNameMatch, which was added in Java 6).
Change-Id: I502e87b50fb305c5c8b061421339c8ceab104640
diff --git a/src/jdwp/jdwp_bits.h b/src/jdwp/jdwp_bits.h
index 344d2de..5536c52 100644
--- a/src/jdwp/jdwp_bits.h
+++ b/src/jdwp/jdwp_bits.h
@@ -67,19 +67,15 @@
}
/*
- * Read a UTF-8 string into newly-allocated storage, and null-terminate it.
- *
- * Returns the string and its length. (The latter is probably unnecessary
- * for the way we're using UTF8.)
+ * Reads a UTF-8 string into a std::string.
*/
-static inline char* ReadNewUtf8String(unsigned char const** ppSrc, size_t* pLength) {
+static inline std::string ReadNewUtf8String(unsigned char const** ppSrc) {
uint32_t length = Read4BE(ppSrc);
- char* buf = (char*) malloc(length+1);
- memcpy(buf, *ppSrc, length);
- buf[length] = '\0';
+ std::string s;
+ s.resize(length);
+ memcpy(&s[0], *ppSrc, length);
(*ppSrc) += length;
- *pLength = length;
- return buf;
+ return s;
}
static inline void Append1BE(std::vector<uint8_t>& bytes, uint8_t value) {