Add nullptr checks in NBLog::DumpReader::handleFormat

Test: dumpsys media.log -r
Bug: 111882126
Change-Id: I04e6d3227a68e4bcde4aecbb293b02684e18c052
diff --git a/media/libnblog/Reader.cpp b/media/libnblog/Reader.cpp
index f86bb99..9bb5e4b 100644
--- a/media/libnblog/Reader.cpp
+++ b/media/libnblog/Reader.cpp
@@ -269,6 +269,15 @@
 EntryIterator DumpReader::handleFormat(const FormatEntry &fmtEntry,
         String8 *timestamp, String8 *body)
 {
+    String8 timestampLocal;
+    String8 bodyLocal;
+    if (timestamp == nullptr) {
+        timestamp = &timestampLocal;
+    }
+    if (body == nullptr) {
+        body = &bodyLocal;
+    }
+
     // log timestamp
     const int64_t ts = fmtEntry.timestamp();
     timestamp->clear();