OSDN Git Service

Fix flaky crashes caused during LogEvent destroy
authorChenjie Yu <cjyu@google.com>
Mon, 22 Jan 2018 23:10:54 +0000 (15:10 -0800)
committerChenjie Yu <cjyu@google.com>
Mon, 22 Jan 2018 23:10:54 +0000 (15:10 -0800)
Test: cts tested
Change-Id: I0329a64506b5838d2572cda0d1b86ad78bae4253

cmds/statsd/src/logd/LogEvent.cpp

index 6782f3f..34fa3c4 100644 (file)
@@ -36,13 +36,13 @@ using std::string;
 using android::util::ProtoOutputStream;
 
 LogEvent::LogEvent(log_msg& msg) {
-    android_log_context context =
+    mContext =
             create_android_log_parser(msg.msg() + sizeof(uint32_t), msg.len() - sizeof(uint32_t));
     mTimestampNs = msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec;
     mLogUid = msg.entry_v4.uid;
-    init(context);
-    if (context) {
-        android_log_destroy(&context);
+    init(mContext);
+    if (mContext) {
+        android_log_destroy(&mContext);
     }
 }