Commit 337e1e20 authored by Dan Kegel's avatar Dan Kegel Committed by Alexandre Julliard

msi: Callers of alloc_msihandle should handle failure.

parent 29f0803c
...@@ -3146,6 +3146,10 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package) ...@@ -3146,6 +3146,10 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
/* FIXME: Need to write more keys to the user registry */ /* FIXME: Need to write more keys to the user registry */
hDb= alloc_msihandle( &package->db->hdr ); hDb= alloc_msihandle( &package->db->hdr );
if (!hDb) {
rc = ERROR_NOT_ENOUGH_MEMORY;
goto end;
}
rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo); rc = MsiGetSummaryInformationW(hDb, NULL, 0, &hSumInfo);
MsiCloseHandle(hDb); MsiCloseHandle(hDb);
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
......
...@@ -190,6 +190,8 @@ UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phD ...@@ -190,6 +190,8 @@ UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phD
if( ret == ERROR_SUCCESS ) if( ret == ERROR_SUCCESS )
{ {
*phDB = alloc_msihandle( &db->hdr ); *phDB = alloc_msihandle( &db->hdr );
if (! *phDB)
ret = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
} }
......
...@@ -124,6 +124,8 @@ UINT WINAPI MsiOpenProductW( LPCWSTR szProduct, MSIHANDLE *phProduct ) ...@@ -124,6 +124,8 @@ UINT WINAPI MsiOpenProductW( LPCWSTR szProduct, MSIHANDLE *phProduct )
if( r == ERROR_SUCCESS ) if( r == ERROR_SUCCESS )
{ {
*phProduct = alloc_msihandle( &package->hdr ); *phProduct = alloc_msihandle( &package->hdr );
if (! *phProduct)
r = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &package->hdr ); msiobj_release( &package->hdr );
} }
return r; return r;
......
...@@ -254,6 +254,8 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, ...@@ -254,6 +254,8 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb,
if( ret == ERROR_SUCCESS ) if( ret == ERROR_SUCCESS )
{ {
*phView = alloc_msihandle( &query->hdr ); *phView = alloc_msihandle( &query->hdr );
if (! *phView)
ret = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &query->hdr ); msiobj_release( &query->hdr );
} }
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
...@@ -365,6 +367,8 @@ UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record) ...@@ -365,6 +367,8 @@ UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
if( ret == ERROR_SUCCESS ) if( ret == ERROR_SUCCESS )
{ {
*record = alloc_msihandle( &rec->hdr ); *record = alloc_msihandle( &rec->hdr );
if (! *record)
ret = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &rec->hdr ); msiobj_release( &rec->hdr );
} }
msiobj_release( &query->hdr ); msiobj_release( &query->hdr );
...@@ -532,6 +536,8 @@ UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hR ...@@ -532,6 +536,8 @@ UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hR
} }
*hRec = alloc_msihandle( &rec->hdr ); *hRec = alloc_msihandle( &rec->hdr );
if (! *hRec)
r = ERROR_NOT_ENOUGH_MEMORY;
out: out:
msiobj_release( &query->hdr ); msiobj_release( &query->hdr );
...@@ -830,6 +836,8 @@ UINT WINAPI MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb, ...@@ -830,6 +836,8 @@ UINT WINAPI MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb,
if( r == ERROR_SUCCESS ) if( r == ERROR_SUCCESS )
{ {
*phRec = alloc_msihandle( &rec->hdr ); *phRec = alloc_msihandle( &rec->hdr );
if (! *phRec)
r = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &rec->hdr ); msiobj_release( &rec->hdr );
} }
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
......
...@@ -365,6 +365,10 @@ static UINT msi_get_word_count( MSIPACKAGE *package ) ...@@ -365,6 +365,10 @@ static UINT msi_get_word_count( MSIPACKAGE *package )
MSIHANDLE suminfo; MSIHANDLE suminfo;
MSIHANDLE hdb = alloc_msihandle( &package->db->hdr ); MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
if (!hdb) {
ERR("Unable to allocate handle\n");
return 0;
}
rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo ); rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
MsiCloseHandle(hdb); MsiCloseHandle(hdb);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
...@@ -584,6 +588,8 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP ...@@ -584,6 +588,8 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP
if( ret == ERROR_SUCCESS ) if( ret == ERROR_SUCCESS )
{ {
*phPackage = alloc_msihandle( &package->hdr ); *phPackage = alloc_msihandle( &package->hdr );
if (! *phPackage)
ret = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &package->hdr ); msiobj_release( &package->hdr );
} }
......
...@@ -76,6 +76,8 @@ UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview ) ...@@ -76,6 +76,8 @@ UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE* phPreview )
*phPreview = alloc_msihandle( &preview->hdr ); *phPreview = alloc_msihandle( &preview->hdr );
msiobj_release( &preview->hdr ); msiobj_release( &preview->hdr );
r = ERROR_SUCCESS; r = ERROR_SUCCESS;
if (! *phPreview)
r = ERROR_NOT_ENOUGH_MEMORY;
} }
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
......
...@@ -468,6 +468,8 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, ...@@ -468,6 +468,8 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase,
*pHandle = alloc_msihandle( &si->hdr ); *pHandle = alloc_msihandle( &si->hdr );
if( *pHandle ) if( *pHandle )
ret = ERROR_SUCCESS; ret = ERROR_SUCCESS;
else
ret = ERROR_NOT_ENOUGH_MEMORY;
msiobj_release( &si->hdr ); msiobj_release( &si->hdr );
} }
......
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