summaryrefslogtreecommitdiff
path: root/runtime/mirror/string.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2015-11-12 16:53:41 -0800
committer Mathieu Chartier <mathieuc@google.com> 2015-11-12 17:31:09 -0800
commit952d608062eec2d7f47f9b45dba935ad8b4d23e5 (patch)
tree6acb2a889c38a76d70771d42c4dfe3ac53116424 /runtime/mirror/string.cc
parentefca362e8c67d5b330dd4ebc312cd45cf2585964 (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.cc6
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;
}