diff options
author | Alex Deymo <deymo@google.com> | 2016-02-16 12:53:58 -0800 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2016-02-16 12:53:58 -0800 |
commit | 2e985f09eb6ffbfa4edae73e8c935edf75ed7e7a (patch) | |
tree | ced84977fe362435b9879099aaedb6b32866afcd /base | |
parent | 5d0701ee9dbfad58a2a4f3bc9c77cc07156eeee5 (diff) | |
download | libchrome-2e985f09eb6ffbfa4edae73e8c935edf75ed7e7a.tar.gz |
Make MessageLoopForIO::current() failure explicit.
When calling MessageLoopForIO::current() without a message loop set
and with debug checks enabled, a DCHECK() will dereference a null
pointer causing the program to segfault.
This patch makes the failure evident adding another DCHECK() with a
clear message.
Bug: None
TEST=FEATURES=test emerge-link libchrome
Change-Id: If69d2e07d0bd93a78001be3e683159380bdd5ff1
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop/message_loop.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h index e78b70497d..d827fb130b 100644 --- a/base/message_loop/message_loop.h +++ b/base/message_loop/message_loop.h @@ -623,6 +623,9 @@ class BASE_EXPORT MessageLoopForIO : public MessageLoop { // Returns the MessageLoopForIO of the current thread. static MessageLoopForIO* current() { MessageLoop* loop = MessageLoop::current(); + DCHECK(loop) << "Can't call MessageLoopForIO::current() when no message " + "loop was created for this thread. Use " + " MessageLoop::current() or MessageLoopForIO::IsCurrent()."; DCHECK_EQ(MessageLoop::TYPE_IO, loop->type()); return static_cast<MessageLoopForIO*>(loop); } |