core: fix memory leak in glob()'s readdir() on WinRT/_WIN32_WCE

readdir() allocates a new buffer for dir->ent.d_name on every call
and overwrites the previous pointer without freeing it. Since
cv::glob() calls readdir() once per directory entry, every call
except the last leaks its allocation. Under _WIN32_WCE, DIR has no
destructor at all, so every allocation leaks, including the last
one.
This commit is contained in:
Sewon Ahn
2026-09-21 13:35:04 +09:00
parent b6a8780959
commit 20b9529bc3
+2 -1
View File
@@ -66,7 +66,7 @@ namespace
#endif
HANDLE handle;
dirent ent;
#ifdef WINRT
#if defined(WINRT) || defined(_WIN32_WCE)
DIR() { }
~DIR()
{
@@ -113,6 +113,7 @@ namespace
char* aname = new char[asize+1];
aname[asize] = 0;
wcstombs(aname, dir->data.cFileName, asize);
delete[] dir->ent.d_name;
dir->ent.d_name = aname;
#else
if (dir->ent.d_name != 0)