mirror of https://github.com/ARMmbed/mbed-os.git
Fix SingletonPtr problems
Check to see if ptr is NULL after acquiring the singleton lock to prevent initialization race conditions. Also explicitly call the constructor for type T.pull/2503/head
parent
862db41be3
commit
707291ab68
|
@ -76,7 +76,9 @@ struct SingletonPtr {
|
|||
T* get() {
|
||||
if (NULL == _ptr) {
|
||||
singleton_lock();
|
||||
_ptr = new (_data) T;
|
||||
if (NULL == _ptr) {
|
||||
_ptr = new (_data) T();
|
||||
}
|
||||
singleton_unlock();
|
||||
}
|
||||
// _ptr was not zero initialized or was
|
||||
|
|
Loading…
Reference in New Issue