Commit f8031d06 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

schedsvc: Fix xml buffer leak (Valgrind).

parent 8d03bef8
...@@ -259,9 +259,10 @@ static int detect_encoding(const void *buffer, DWORD size) ...@@ -259,9 +259,10 @@ static int detect_encoding(const void *buffer, DWORD size)
static HRESULT read_xml(const WCHAR *name, WCHAR **xml) static HRESULT read_xml(const WCHAR *name, WCHAR **xml)
{ {
char *src, *buff;
HANDLE hfile; HANDLE hfile;
DWORD size, attrs; DWORD size, attrs;
char *src; HRESULT hr = S_OK;
int cp; int cp;
attrs = GetFileAttributesW(name); attrs = GetFileAttributesW(name);
...@@ -275,7 +276,7 @@ static HRESULT read_xml(const WCHAR *name, WCHAR **xml) ...@@ -275,7 +276,7 @@ static HRESULT read_xml(const WCHAR *name, WCHAR **xml)
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
size = GetFileSize(hfile, NULL); size = GetFileSize(hfile, NULL);
src = heap_alloc(size + 2); buff = src = heap_alloc(size + 2);
if (!src) if (!src)
{ {
CloseHandle(hfile); CloseHandle(hfile);
...@@ -300,9 +301,13 @@ static HRESULT read_xml(const WCHAR *name, WCHAR **xml) ...@@ -300,9 +301,13 @@ static HRESULT read_xml(const WCHAR *name, WCHAR **xml)
size = MultiByteToWideChar(cp, 0, src, -1, NULL, 0); size = MultiByteToWideChar(cp, 0, src, -1, NULL, 0);
*xml = heap_alloc(size * sizeof(WCHAR)); *xml = heap_alloc(size * sizeof(WCHAR));
if (!*xml) return E_OUTOFMEMORY; if (*xml)
MultiByteToWideChar(cp, 0, src, -1, *xml, size); MultiByteToWideChar(cp, 0, src, -1, *xml, size);
return S_OK; else
hr = E_OUTOFMEMORY;
heap_free(buff);
return hr;
} }
HRESULT __cdecl SchRpcRetrieveTask(const WCHAR *path, const WCHAR *languages, ULONG *n_languages, WCHAR **xml) HRESULT __cdecl SchRpcRetrieveTask(const WCHAR *path, const WCHAR *languages, ULONG *n_languages, WCHAR **xml)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment