https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fdfef818ef5dcb4d0132d…
commit fdfef818ef5dcb4d0132da8fe4e91eb00415db24
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jun 6 16:33:44 2019 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Jun 6 17:07:38 2019 +0200
[BROWSEUI] Fix CSHEnumClassesOfCategories::Initialize() parameters validation.
(#1559)
CORE-11711
---
.../shellbars/CSHEnumClassesOfCategories.cpp | 30 ++++++++++++++--------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/dll/win32/browseui/shellbars/CSHEnumClassesOfCategories.cpp
b/dll/win32/browseui/shellbars/CSHEnumClassesOfCategories.cpp
index c2915a725fc..7f448a2f1ce 100644
--- a/dll/win32/browseui/shellbars/CSHEnumClassesOfCategories.cpp
+++ b/dll/win32/browseui/shellbars/CSHEnumClassesOfCategories.cpp
@@ -254,17 +254,16 @@ HRESULT CSHEnumClassesOfCategories::Initialize(ULONG cImplemented,
CATID *pImple
if (!fDsa)
return E_FAIL;
- if (cRequired > 0 || cImplemented == (ULONG)-1)
- {
- FIXME("Implement required categories class enumeration\n");
- return E_NOTIMPL;
- }
-
- // Don't do anything if we have nothing
- if (cRequired == 0 && cImplemented == (ULONG)-1)
- return E_FAIL;
+ // Parameter validation:
+ // - We must have at least one category to manage.
+ // - The array pointers must not be NULL if there is a non-zero
+ // element count specified for them.
+ if (cImplemented == 0 && cRequired == 0)
+ return E_INVALIDARG;
+ if ((cImplemented && !pImplemented) || (cRequired && !pRequired))
+ return E_INVALIDARG;
- // For each implemented category, create a cache and add it to our local DSA
+ // For each implemented category, create a cache and add it to our local DSA.
for (i = 0; i < cImplemented; i++)
{
CComCatCachedCategory cachedCat;
@@ -273,6 +272,17 @@ HRESULT CSHEnumClassesOfCategories::Initialize(ULONG cImplemented,
CATID *pImple
return hr;
cachedCat.WriteCacheToDSA(fDsa);
}
+
+ // TODO: Implement caching of the required categories.
+ if (cRequired > 0)
+ {
+ FIXME("Implement required categories class enumeration\n");
+
+ // Only fail in case we didn't look at the implemented categories.
+ if (cImplemented == 0)
+ return E_NOTIMPL;
+ }
+
return S_OK;
}