Stop TestInfo::Run() calling a function through null pointer

If the object was never created then trying to call &Test::DeleteSelf_
will dereference a null pointer, with undefined behaviour.

Fixes #845
This commit is contained in:
Jonathan Wakely 2016-12-23 01:56:14 +00:00 committed by Knut Omang
parent 45a2134b09
commit 99d74cf9f8

View File

@ -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");
}
result_.set_elapsed_time(internal::GetTimeInMillis() - start);