QFileSystemEngine/Win: fix incorrect buffer size in currentPath()

We've just allocated a buffer of 'size' size, which is bigger than
PATH_MAX, but told GetCurrentDirectory() that its size is PATH_MAX.

Fixes: QTBUG-103852
Pick-to: 5.15 6.2 6.3
Change-Id: Ibcde9b9795ad42ac9978fffd16f2ba2cd8712cb7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-26 11:11:54 -07:00
parent 51ac14a4f7
commit e21522b8bf

View File

@ -1647,7 +1647,7 @@ QFileSystemEntry QFileSystemEngine::currentPath()
if (size != 0) {
if (size > PATH_MAX) {
wchar_t *newCurrentName = new wchar_t[size];
if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0)
if (::GetCurrentDirectory(size, newCurrentName) != 0)
ret = QString::fromWCharArray(newCurrentName, size);
delete [] newCurrentName;
} else {