diff options
author | Christopher Ferris <cferris@google.com> | 2015-04-24 17:23:53 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2015-04-27 11:45:29 -0700 |
commit | 8a35405e00ad3a722750e37c8eae1c3e1cc0afb0 (patch) | |
tree | 62487b86a0e6bcfc7d2ba948f289956c6d43d3c5 | |
parent | d74a1bf310a6a5ad2d770fcd76735cbc617d64eb (diff) | |
download | art-8a35405e00ad3a722750e37c8eae1c3e1cc0afb0.zip art-8a35405e00ad3a722750e37c8eae1c3e1cc0afb0.tar.gz art-8a35405e00ad3a722750e37c8eae1c3e1cc0afb0.tar.bz2 |
Fix mismatched malloc/free delete/new.
Modify the monitor code to override the delete operator. The problem
is the new operator is overloaded to return a pointer returned by
posix_memalign, but then it's freed with a delete, not a free call.
Also, fix the debugger code to use the [] for a std::unique_ptr to
match how the value is actually allocated.
Both problems found by ASAN.
Bug: 18202869
Change-Id: I2f3a2c02a7f35399b7ba6717b08a035089fab00d
-rw-r--r-- | runtime/debugger.cc | 2 | ||||
-rw-r--r-- | runtime/monitor.h | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc index f3ce552..db268dd 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -4774,7 +4774,7 @@ class StringTable { for (const std::string& str : table_) { const char* s = str.c_str(); size_t s_len = CountModifiedUtf8Chars(s); - std::unique_ptr<uint16_t> s_utf16(new uint16_t[s_len]); + std::unique_ptr<uint16_t[]> s_utf16(new uint16_t[s_len]); ConvertModifiedUtf8ToUtf16(s_utf16.get(), s); JDWP::AppendUtf16BE(bytes, s_utf16.get(), s_len); } diff --git a/runtime/monitor.h b/runtime/monitor.h index 95e4460..b7245c1 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -141,6 +141,10 @@ class Monitor { CHECK_EQ(error, 0) << strerror(error); return result; } + + void operator delete(void* ptr) { + free(ptr); + } #endif private: |