Properly resize the buffer based on ERROR_MORE_DATA.

Also remember to free the allocated buffer.
This commit is contained in:
Aric Stewart 2005-07-11 20:36:58 +00:00 committed by Alexandre Julliard
parent 0f394ae6dc
commit 9170cc8225
1 changed files with 12 additions and 1 deletions

View File

@ -873,9 +873,18 @@ UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex,
rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL,
NULL, (LPBYTE)full_buffer, &full_buffer_size);
if (rc == ERROR_MORE_DATA)
{
HeapFree(GetProcessHeap(),0,full_buffer);
full_buffer_size+=sizeof(WCHAR);
full_buffer = HeapAlloc(GetProcessHeap(),0,full_buffer_size);
rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL,
NULL, (LPBYTE)full_buffer, &full_buffer_size);
}
RegCloseKey(key);
if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
if (rc == ERROR_SUCCESS)
{
if (lpApplicationDataBuf && pcchApplicationDataBuf)
{
@ -898,6 +907,8 @@ UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex,
debugstr_w(lpApplicationDataBuf));
}
HeapFree(GetProcessHeap(),0,full_buffer);
return rc;
}