Commit 6edc9517 authored by Gavriel State's avatar Gavriel State Committed by Alexandre Julliard

OleRegGetUserType did return an unterminated ASCII string instead of an

OLESTR (wide characters).
parent ef76a1c9
...@@ -392,13 +392,14 @@ HRESULT WINAPI OleRegGetUserType( ...@@ -392,13 +392,14 @@ HRESULT WINAPI OleRegGetUserType(
DWORD dwFormOfType, DWORD dwFormOfType,
LPOLESTR* pszUserType) LPOLESTR* pszUserType)
{ {
char xclsid[50]; char xclsid[50];
char keyName[60]; char keyName[60];
DWORD dwKeyType; DWORD dwKeyType;
DWORD cbData; DWORD cbData;
HKEY clsidKey; HKEY clsidKey;
LONG hres; LONG hres;
LPBYTE buffer;
HRESULT retVal;
/* /*
* Initialize the out parameter. * Initialize the out parameter.
*/ */
...@@ -446,7 +447,7 @@ HRESULT WINAPI OleRegGetUserType( ...@@ -446,7 +447,7 @@ HRESULT WINAPI OleRegGetUserType(
/* /*
* Allocate a buffer for the registry value. * Allocate a buffer for the registry value.
*/ */
*pszUserType = CoTaskMemAlloc(cbData); *pszUserType = CoTaskMemAlloc(cbData*2);
if (*pszUserType==NULL) if (*pszUserType==NULL)
{ {
...@@ -454,24 +455,41 @@ HRESULT WINAPI OleRegGetUserType( ...@@ -454,24 +455,41 @@ HRESULT WINAPI OleRegGetUserType(
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
buffer = HeapAlloc(GetProcessHeap(), 0, cbData);
if (buffer == NULL)
{
RegCloseKey(clsidKey);
CoTaskMemFree(*pszUserType);
*pszUserType=NULL;
return E_OUTOFMEMORY;
}
hres = RegQueryValueExA(clsidKey, hres = RegQueryValueExA(clsidKey,
"", "",
NULL, NULL,
&dwKeyType, &dwKeyType,
(LPBYTE)*pszUserType, buffer,
&cbData); &cbData);
RegCloseKey(clsidKey); RegCloseKey(clsidKey);
if (hres!=ERROR_SUCCESS) if (hres!=ERROR_SUCCESS)
{ {
CoTaskMemFree(*pszUserType); CoTaskMemFree(*pszUserType);
*pszUserType=NULL; *pszUserType=NULL;
return REGDB_E_READREGDB; retVal = REGDB_E_READREGDB;
} }
else
{
lstrcpyAtoW(*pszUserType, buffer);
retVal = S_OK;
}
HeapFree(GetProcessHeap(), 0, buffer);
return S_OK; return retVal;
} }
/*********************************************************************** /***********************************************************************
......
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