From e82b3276053db4e76776edff0da564d107bb31ab Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 2 Apr 2019 12:31:56 +0200 Subject: [PATCH 1/4] sanitize shared_ptr --- include/fc/shared_ptr.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/shared_ptr.hpp b/include/fc/shared_ptr.hpp index cd6a94c..a07ec46 100644 --- a/include/fc/shared_ptr.hpp +++ b/include/fc/shared_ptr.hpp @@ -46,7 +46,7 @@ namespace fc { shared_ptr( shared_ptr&& p ) :_ptr(p._ptr){ p._ptr = nullptr; } - ~shared_ptr() { if( nullptr != _ptr ) { _ptr->release(); } } + ~shared_ptr() { if( nullptr != _ptr ) { _ptr->release(); _ptr = nullptr; } } shared_ptr& reset( T* v = nullptr, bool inc = false ) { if( v == _ptr ) return *this; From a188a95f2c63fad27436372a9c671fe84a816a60 Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 2 Apr 2019 12:33:04 +0200 Subject: [PATCH 2/4] extend openssl cleanup --- src/crypto/openssl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/crypto/openssl.cpp b/src/crypto/openssl.cpp index 215708d..3f8df03 100644 --- a/src/crypto/openssl.cpp +++ b/src/crypto/openssl.cpp @@ -39,7 +39,10 @@ namespace fc ~openssl_scope() { + FIPS_mode_set(0); + CONF_modules_unload(1); EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); } }; From 918502e29e608a2ddf64c8f870274b4cc9bc335d Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 2 Apr 2019 12:37:18 +0200 Subject: [PATCH 3/4] invalidate pointer to deleted object --- src/thread/thread_d.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 5353606..0c11986 100644 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -52,6 +52,7 @@ namespace fc { ~thread_d() { delete current; + current = nullptr; fc::context* temp; for (fc::context* ready_context : ready_heap) delete ready_context; From 95ca36d02d6404b2bb7d8d71da2b60abf7cb7201 Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 2 Apr 2019 12:40:13 +0200 Subject: [PATCH 4/4] properly cleanup previous current thread object --- src/thread/thread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread/thread.cpp b/src/thread/thread.cpp index 0d1a9aa..69d4bbf 100644 --- a/src/thread/thread.cpp +++ b/src/thread/thread.cpp @@ -77,6 +77,7 @@ namespace fc { try { set_thread_name(name.c_str()); // set thread's name for the debugger to display this->my = new thread_d( *this, notifier ); + cleanup(); current_thread() = this; p->set_value(); exec(); @@ -126,8 +127,10 @@ namespace fc { } void thread::cleanup() { - delete current_thread(); - current_thread() = nullptr; + if ( current_thread() ) { + delete current_thread(); + current_thread() = nullptr; + } } const string& thread::name()const