Ensure correct destruction order in RtcEventLogImplTest

Bug: b/269744492
Change-Id: I0b7b92ec31baf3515562adde7617de0873cfd537
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/298882
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39653}
diff --git a/logging/rtc_event_log/rtc_event_log_impl_unittest.cc b/logging/rtc_event_log/rtc_event_log_impl_unittest.cc
index 05f7e55..1e8799b 100644
--- a/logging/rtc_event_log/rtc_event_log_impl_unittest.cc
+++ b/logging/rtc_event_log/rtc_event_log_impl_unittest.cc
@@ -98,6 +98,7 @@
   static constexpr Timestamp kStartTime = Timestamp::Seconds(1);
 
   GlobalSimulatedTimeController time_controller_{kStartTime};
+  std::string written_data_;  // This must be destroyed after the event_log_.
   std::unique_ptr<MockEventEncoder> encoder_ =
       std::make_unique<MockEventEncoder>();
   MockEventEncoder* encoder_ptr_ = encoder_.get();
@@ -107,7 +108,6 @@
   RtcEventLogImpl event_log_{std::move(encoder_),
                              time_controller_.GetTaskQueueFactory(),
                              kMaxEventsInHistory, kMaxEventsInConfigHistory};
-  std::string written_data_;
 };
 
 TEST_F(RtcEventLogImplTest, WritesHeaderAndEventsAndTrailer) {