Commit 4a88562e authored by Alexandre Julliard's avatar Alexandre Julliard

msi: Reset the MsiEnumProductsW index on failure.

parent a83563aa
...@@ -1236,17 +1236,13 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid) ...@@ -1236,17 +1236,13 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
if (index && index - last_index != 1) if (index && index - last_index != 1)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
key = 0;
r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_LocalClassesProd, &key); r = RegCreateKeyW(HKEY_LOCAL_MACHINE, szInstaller_LocalClassesProd, &key);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
return ERROR_NO_MORE_ITEMS;
r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &machine_count, NULL, NULL, r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &machine_count, NULL, NULL,
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
{
RegCloseKey(key);
return ERROR_NO_MORE_ITEMS;
}
if (machine_count && index <= machine_count) if (machine_count && index <= machine_count)
{ {
...@@ -1261,26 +1257,23 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid) ...@@ -1261,26 +1257,23 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
} }
RegCloseKey(key); RegCloseKey(key);
key = 0;
r = get_user_sid(&usersid); r = get_user_sid(&usersid);
if (r != ERROR_SUCCESS || !usersid) if (r != ERROR_SUCCESS || !usersid)
{ {
ERR("Failed to retrieve user SID: %d\n", r); ERR("Failed to retrieve user SID: %d\n", r);
last_index = 0;
return r; return r;
} }
sprintfW(keypath, szInstaller_LocalManaged_fmt, usersid); sprintfW(keypath, szInstaller_LocalManaged_fmt, usersid);
LocalFree(usersid); LocalFree(usersid);
r = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, &key); r = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, &key);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
return ERROR_NO_MORE_ITEMS;
r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &managed_count, NULL, NULL, r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &managed_count, NULL, NULL,
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
{
RegCloseKey(key);
return ERROR_NO_MORE_ITEMS;
}
if (managed_count && index <= machine_count + managed_count) if (managed_count && index <= machine_count + managed_count)
{ {
...@@ -1295,17 +1288,13 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid) ...@@ -1295,17 +1288,13 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
} }
RegCloseKey(key); RegCloseKey(key);
key = 0;
r = RegCreateKeyW(HKEY_CURRENT_USER, szUserProduct, &key); r = RegCreateKeyW(HKEY_CURRENT_USER, szUserProduct, &key);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
return ERROR_NO_MORE_ITEMS;
r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &unmanaged_count, NULL, NULL, r = RegQueryInfoKeyW(key, NULL, NULL, NULL, &unmanaged_count, NULL, NULL,
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS ) goto failed;
{
RegCloseKey(key);
return ERROR_NO_MORE_ITEMS;
}
if (unmanaged_count && index <= machine_count + managed_count + unmanaged_count) if (unmanaged_count && index <= machine_count + managed_count + unmanaged_count)
{ {
...@@ -1318,8 +1307,9 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid) ...@@ -1318,8 +1307,9 @@ UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
} }
failed:
RegCloseKey(key); RegCloseKey(key);
last_index = 0;
return ERROR_NO_MORE_ITEMS; return ERROR_NO_MORE_ITEMS;
} }
......
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