Skip to content

Commit 7bd3ccd

Browse files
committed
Merge pull request opencv#8713 from grundman:patch-6
2 parents 37b1bc9 + cf4e9e5 commit 7bd3ccd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/core/src/matrix.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,19 @@ class StdMatAllocator : public MatAllocator
222222
};
223223
namespace
224224
{
225-
MatAllocator* g_matAllocator = NULL;
225+
MatAllocator* volatile g_matAllocator = NULL;
226226
}
227227

228228

229229
MatAllocator* Mat::getDefaultAllocator()
230230
{
231231
if (g_matAllocator == NULL)
232232
{
233-
g_matAllocator = getStdAllocator();
233+
cv::AutoLock lock(cv::getInitializationMutex());
234+
if (g_matAllocator == NULL)
235+
{
236+
g_matAllocator = getStdAllocator();
237+
}
234238
}
235239
return g_matAllocator;
236240
}

0 commit comments

Comments
 (0)