Avoids race during VideoStreamEncoder unittest teardown
The ScopedFakeClock contains a lock. Due to declaration order, this is the first member of VideoStreamEncoderTest to be destroyed. However, there are cyclic tasks that may still be running at that time, and they may try to read the time, so if we're unlucky they may trigger a use after free condition. This only affects test and is simply solved by moving the declaration to before the classes that uses it. Bug: webrtc:10929 Change-Id: I998d5ced877f355e4a45ee5cf75b2eb75faa6113 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150795 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29008}
This commit is contained in:
@ -1075,6 +1075,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
int codec_width_;
|
||||
int codec_height_;
|
||||
int max_framerate_;
|
||||
rtc::ScopedFakeClock fake_clock_;
|
||||
const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
|
||||
TestEncoder fake_encoder_;
|
||||
test::VideoEncoderProxyFactory encoder_factory_;
|
||||
@ -1083,7 +1084,6 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
TestSink sink_;
|
||||
AdaptingFrameForwarder video_source_;
|
||||
std::unique_ptr<VideoStreamEncoderUnderTest> video_stream_encoder_;
|
||||
rtc::ScopedFakeClock fake_clock_;
|
||||
};
|
||||
|
||||
TEST_F(VideoStreamEncoderTest, EncodeOneFrame) {
|
||||
|
Reference in New Issue
Block a user