Skip to content

Commit b40c5a8

Browse files
committed
Fixing memory leak in locale utility.
1 parent 51bc52c commit b40c5a8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,25 @@ scoped_c_thread_locale::xplat_locale scoped_c_thread_locale::c_locale()
6060
scoped_c_thread_locale::xplat_locale *clocale = new scoped_c_thread_locale::xplat_locale();
6161
#ifdef _WIN32
6262
*clocale = _create_locale(LC_ALL, "C");
63-
if (clocale == nullptr)
63+
if (*clocale == nullptr)
6464
{
6565
throw std::runtime_error("Unable to create 'C' locale.");
6666
}
6767
auto deleter = [](scoped_c_thread_locale::xplat_locale *clocale)
6868
{
6969
_free_locale(*clocale);
70+
delete clocale;
7071
};
7172
#else
7273
*clocale = newlocale(LC_ALL, "C", nullptr);
73-
if (clocale == nullptr)
74+
if (*clocale == nullptr)
7475
{
7576
throw std::runtime_error("Unable to create 'C' locale.");
7677
}
7778
auto deleter = [](scoped_c_thread_locale::xplat_locale *clocale)
7879
{
7980
freelocale(*clocale);
81+
delete clocale;
8082
};
8183
#endif
8284
g_c_locale = std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)>(clocale, deleter);

0 commit comments

Comments
 (0)