diff options
| author | 2015-11-12 16:53:41 -0800 | |
|---|---|---|
| committer | 2015-11-12 17:31:09 -0800 | |
| commit | 952d608062eec2d7f47f9b45dba935ad8b4d23e5 (patch) | |
| tree | 6acb2a889c38a76d70771d42c4dfe3ac53116424 /runtime/mirror/string.cc | |
| parent | efca362e8c67d5b330dd4ebc312cd45cf2585964 (diff) | |
Add missing null check to String::ToCharArray
Added test.
Bug: 25641543
Change-Id: Ic9a21ce8bc530dbedf14334ad47f5faa90ae4ddc
Diffstat (limited to 'runtime/mirror/string.cc')
| -rw-r--r-- | runtime/mirror/string.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc index 45610dccc8..be869d4e6a 100644 --- a/runtime/mirror/string.cc +++ b/runtime/mirror/string.cc @@ -254,7 +254,11 @@ CharArray* String::ToCharArray(Thread* self) { StackHandleScope<1> hs(self); Handle<String> string(hs.NewHandle(this)); CharArray* result = CharArray::Alloc(self, GetLength()); - memcpy(result->GetData(), string->GetValue(), string->GetLength() * sizeof(uint16_t)); + if (result != nullptr) { + memcpy(result->GetData(), string->GetValue(), string->GetLength() * sizeof(uint16_t)); + } else { + self->AssertPendingOOMException(); + } return result; } |