Fixing pseudotcp_parser_fuzzer crash with NO_MAIN_THREAD_WRAPPING.

The test was trying to solve this problem already with AutoThread, but
the order of variable declaration was causing it to be created after
"rtc::Thread::Current()" was already called.

BUG=chromium:701262
TBR=pbos@webrtc.org

Review-Url: https://codereview.webrtc.org/2858343002
Cr-Commit-Position: refs/heads/master@{#18019}
This commit is contained in:
deadbeef 2017-05-04 12:16:28 -07:00 committed by Commit bot
parent d1d247fa3c
commit 70719a773d

View File

@ -31,19 +31,18 @@ class FakeIPseudoTcpNotify : public cricket::IPseudoTcpNotify {
struct Environment {
explicit Environment(cricket::IPseudoTcpNotify* notifier):
ptcp(new cricket::PseudoTcp(notifier, 0)) {
ptcp(notifier, 0) {
}
cricket::PseudoTcp* const ptcp;
// We need the thread to avoid some uninteresting crashes, since the
// production code expects there to be a thread object available.
rtc::AutoThread thread;
cricket::PseudoTcp ptcp;
};
Environment* env = new Environment(new FakeIPseudoTcpNotify());
void FuzzOneInput(const uint8_t* data, size_t size) {
env->ptcp->NotifyPacket(reinterpret_cast<const char*>(data), size);
env->ptcp.NotifyPacket(reinterpret_cast<const char*>(data), size);
}
} // namespace webrtc