mCallback defined in BringYourOwnSection should be an object instead of a reference.
The referenced object could be destroyed and result in native crash when
mCallback is used.
Bug: 156536687
Test: manual test with registering a section from an app
Change-Id: Ie36c0e6e64be1246539f12999f037c24377686dd
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp
index 114cbb8..61e5eb0 100644
--- a/cmds/incidentd/src/Section.cpp
+++ b/cmds/incidentd/src/Section.cpp
@@ -876,7 +876,9 @@
status_t BringYourOwnSection::BlockingCall(unique_fd& pipeWriteFd) const {
android::os::ParcelFileDescriptor pfd(std::move(pipeWriteFd));
- mCallback->onDumpSection(pfd);
+ if(mCallback != nullptr) {
+ mCallback->onDumpSection(pfd);
+ }
return NO_ERROR;
}