From c7ccde69a828c493d0cb291d5151c0cc493a29f1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 14 Jan 2016 14:38:37 +0300 Subject: [PATCH] fix TLS implementation (closes #5967) --- modules/core/src/system.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 5fbb453742..768280e1a6 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1085,11 +1085,14 @@ public: for(size_t i = 0; i < threads.size(); i++) { - std::vector& thread_slots = threads[i]->slots; - if (thread_slots.size() > slotIdx && thread_slots[slotIdx]) + if(threads[i]) { - dataVec.push_back(thread_slots[slotIdx]); - threads[i]->slots[slotIdx] = 0; + std::vector& thread_slots = threads[i]->slots; + if (thread_slots.size() > slotIdx && thread_slots[slotIdx]) + { + dataVec.push_back(thread_slots[slotIdx]); + threads[i]->slots[slotIdx] = 0; + } } } @@ -1116,9 +1119,12 @@ public: for(size_t i = 0; i < threads.size(); i++) { - std::vector& thread_slots = threads[i]->slots; - if (thread_slots.size() > slotIdx && thread_slots[slotIdx]) - dataVec.push_back(thread_slots[slotIdx]); + if(threads[i]) + { + std::vector& thread_slots = threads[i]->slots; + if (thread_slots.size() > slotIdx && thread_slots[slotIdx]) + dataVec.push_back(thread_slots[slotIdx]); + } } }