diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2016-12-23 01:56:14 (GMT) |
---|---|---|
committer | Knut Omang <knut.omang@oracle.com> | 2019-02-11 19:15:30 (GMT) |
commit | 48e6f1f387e6e67489d7b1422239c1be637006cb (patch) | |
tree | affc94728e99b13337fdc400f0abd9aa957b040f | |
parent | 9a502a5b14b4a6160103c1f2c64331772878d86a (diff) | |
download | googletest-48e6f1f387e6e67489d7b1422239c1be637006cb.zip googletest-48e6f1f387e6e67489d7b1422239c1be637006cb.tar.gz googletest-48e6f1f387e6e67489d7b1422239c1be637006cb.tar.bz2 |
Stop TestInfo::Run() calling a function through null pointerrefs/pull/2112/head
If the object was never created then trying to call &Test::DeleteSelf_
will dereference a null pointer, with undefined behaviour.
Fixes #845
-rw-r--r-- | googletest/src/gtest.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index d1cfb53..cc7305c 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2675,10 +2675,12 @@ void TestInfo::Run() { test->Run(); } + if (test != NULL) { // Deletes the test object. impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( - test, &Test::DeleteSelf_, "the test fixture's destructor"); + test, &Test::DeleteSelf_, "the test fixture's destructor"); + } result_.set_elapsed_time(internal::GetTimeInMillis() - start); |