You have to pass string length without terminal null to SysAllocStringLen.
This fixes following vbscript code: Temp_Path = strSystemRoot & "" & fso.GetTempName() & ".vbs"
From: Robert Wilhelm robert.wilhelm@gmx.net
--- dlls/scrrun/tests/filesystem.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 1ba0e81a2d1..5ec2d3edea5 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -485,6 +485,7 @@ static void test_GetTempName(void) hr = IFileSystem3_GetTempName(fs3, &result); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!!wcsstr( result,L".tmp"), "GetTempName returned %s, expected .tmp suffix\n", debugstr_w(result)); + todo_wine ok(SysStringLen(result) == lstrlenW(result),"GetTempName returned %s, has incorrect string len.\n", debugstr_w(result)); SysFreeString(result); }
From: Robert Wilhelm robert.wilhelm@gmx.net
You have to pass string length without terminal null to SysAllocStringLen.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53569 --- dlls/scrrun/filesystem.c | 2 +- dlls/scrrun/tests/filesystem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 35b43e2f124..458c550a004 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -3449,7 +3449,7 @@ static HRESULT WINAPI filesys_GetTempName(IFileSystem3 *iface, BSTR *result) if (!result) return E_POINTER;
- if (!(*result = SysAllocStringLen(NULL, 13))) + if (!(*result = SysAllocStringLen(NULL, 12))) return E_OUTOFMEMORY;
if(!RtlGenRandom(&random, sizeof(random))) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 5ec2d3edea5..5e88eaec46b 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -485,7 +485,7 @@ static void test_GetTempName(void) hr = IFileSystem3_GetTempName(fs3, &result); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!!wcsstr( result,L".tmp"), "GetTempName returned %s, expected .tmp suffix\n", debugstr_w(result)); - todo_wine ok(SysStringLen(result) == lstrlenW(result),"GetTempName returned %s, has incorrect string len.\n", debugstr_w(result)); + ok(SysStringLen(result) == lstrlenW(result),"GetTempName returned %s, has incorrect string len.\n", debugstr_w(result)); SysFreeString(result); }
From: Robert Wilhelm robert.wilhelm@gmx.net
--- dlls/scrrun/filesystem.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 458c550a004..37753a84b5e 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -3453,7 +3453,11 @@ static HRESULT WINAPI filesys_GetTempName(IFileSystem3 *iface, BSTR *result) return E_OUTOFMEMORY;
if(!RtlGenRandom(&random, sizeof(random))) + { + SysFreeString(*result); return E_FAIL; + } + swprintf(*result, 13, L"rad%05X.tmp", random & 0xfffff); return S_OK; }
This merge request was approved by Nikolay Sivov.