From 48e6f1f387e6e67489d7b1422239c1be637006cb Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 23 Dec 2016 01:56:14 +0000 Subject: 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 --- googletest/src/gtest.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- cgit v0.12