diff options
author | Vic Yang <victoryang@google.com> | 2019-09-27 21:03:09 -0700 |
---|---|---|
committer | Vic Yang <victoryang@google.com> | 2019-09-27 21:07:00 -0700 |
commit | 5a141424e660165122f2ab40f28cd4af3bc96833 (patch) | |
tree | 634088f58286344a659ee722ff90e53bcdc2d4cc /libutils/String16.cpp | |
parent | 34aba6a690811dac48568fe9679e895b80bcb069 (diff) |
Fix memory leak in String16
Newly allocated SharedBuffer already has reference count 1, so we
should not call acquire().
Bug: 141764153
Test: Run String16Test.* with ASan that was able to detect the leak
without this change.
Change-Id: Ib8b1b707b028386d717414d8c5ec5ea7b4b59464
Diffstat (limited to 'libutils/String16.cpp')
-rw-r--r-- | libutils/String16.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/libutils/String16.cpp b/libutils/String16.cpp index 5c3cf3261..e2a8c59a0 100644 --- a/libutils/String16.cpp +++ b/libutils/String16.cpp @@ -346,7 +346,6 @@ void* String16::edit() { if (isStaticString()) { buf = static_cast<SharedBuffer*>(alloc((size() + 1) * sizeof(char16_t))); if (buf) { - buf->acquire(); memcpy(buf->data(), mString, (size() + 1) * sizeof(char16_t)); } } else { @@ -365,7 +364,6 @@ void* String16::editResize(size_t newSize) { } buf = static_cast<SharedBuffer*>(alloc(newSize)); if (buf) { - buf->acquire(); memcpy(buf->data(), mString, copySize); } } else { |