diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-18 03:14:13 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-18 03:14:13 +0000 |
commit | 5eeab7f62dc94a670e02d69fff00d5ca6f359644 (patch) | |
tree | 9c1392794a0908fa504cdb3a8ef015cbcc0a886a | |
parent | 29c1d68736696c9f5dd5b63f2cb0fc0c28ce1543 (diff) | |
parent | 62b8eb7c6ae9f3ef546c35ff741c7cbbfea106a6 (diff) | |
download | perfetto-android10-c2f2-s2-release.tar.gz |
Snap for 5736565 from 62b8eb7c6ae9f3ef546c35ff741c7cbbfea106a6 to qt-c2f2-releaseandroid-10.0.0_r9android-10.0.0_r8android-10.0.0_r7android-10.0.0_r14android-10.0.0_r13android-10.0.0_r12android10-c2f2-s2-releaseandroid10-c2f2-s1-releaseandroid10-c2f2-release
Change-Id: I3216b858e6fc1b679f863e68624714b49fbb3204
-rw-r--r-- | src/profiling/memory/malloc_hooks.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/profiling/memory/malloc_hooks.cc b/src/profiling/memory/malloc_hooks.cc index 6070a03cb..387fd842d 100644 --- a/src/profiling/memory/malloc_hooks.cc +++ b/src/profiling/memory/malloc_hooks.cc @@ -501,6 +501,17 @@ int HEAPPROFD_ADD_PREFIX(_posix_memalign)(void** memptr, // sure that the address is not reused before we've processed the deallocation // (which includes assigning a sequence id to it). void HEAPPROFD_ADD_PREFIX(_free)(void* pointer) { + // free on a nullptr is valid but has no effect. Short circuit here, for + // various advantages: + // * More efficient + // * Notably printf calls free(nullptr) even when it is used in a way + // malloc-free way, as it unconditionally frees the pointer even if + // it was never written to. + // Short circuiting here makes it less likely to accidentally build + // infinite recursion. + if (pointer == nullptr) + return; + const MallocDispatch* dispatch = GetDispatch(); std::shared_ptr<perfetto::profiling::Client> client; { |