mirror of
https://github.com/opencv/opencv.git
synced 2026-09-25 04:09:57 +03:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user