summaryrefslogtreecommitdiff
path: root/src/md
diff options
context:
space:
mode:
authorshion <tishion@users.noreply.github.com>2016-04-29 16:33:40 -0500
committerJan Kotas <jkotas@microsoft.com>2016-04-29 14:33:40 -0700
commit66c8e59fcc4cbf384f2170aea07e9c968a7f97d7 (patch)
tree0a334df473f7bc0024f3e462d5e8390656241826 /src/md
parent14ecf5a950b248d2499fc18be322f4f8c606e4c6 (diff)
downloadcoreclr-66c8e59fcc4cbf384f2170aea07e9c968a7f97d7.tar.gz
coreclr-66c8e59fcc4cbf384f2170aea07e9c968a7f97d7.tar.bz2
coreclr-66c8e59fcc4cbf384f2170aea07e9c968a7f97d7.zip
Add query handling of IUnknown for MergeTokenManager and CMapToken (#4563)
Diffstat (limited to 'src/md')
-rw-r--r--src/md/enc/rwutil.cpp48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/md/enc/rwutil.cpp b/src/md/enc/rwutil.cpp
index cb8d9174b1..874d972716 100644
--- a/src/md/enc/rwutil.cpp
+++ b/src/md/enc/rwutil.cpp
@@ -1001,12 +1001,29 @@ ULONG MergeTokenManager::Release()
HRESULT MergeTokenManager::QueryInterface(REFIID riid, void **ppUnk)
{
- *ppUnk = 0;
+ if (ppUnk == NULL)
+ return E_INVALIDARG;
+
+ if (IsEqualIID(riid, IID_IMapToken))
+ {
+ //*ppUnk = (IUnknown *) (IMapToken *) this;
+ // it should return the accurate type requested,
+ // if IUnknown is returned, it will finally converted to IMapToken*
+ *ppUnk = (IMapToken *) this;
+ }
+ else if (IsEqualIID(riid, IID_IUnknown))
+ {
+ // add query handling for IUnknown
+ // this upcasting (converting a derived-class
+ // reference or pointer to a base-class) is safe
+ *ppUnk = (IUnknown *) this;
+ }
+ else
+ {
+ *ppUnk = NULL;
+ return (E_NOINTERFACE);
+ }
- if (riid == IID_IMapToken)
- *ppUnk = (IUnknown *) (IMapToken *) this;
- else
- return (E_NOINTERFACE);
AddRef();
return (S_OK);
} // TokenManager::QueryInterface
@@ -1121,12 +1138,23 @@ ULONG CMapToken::Release()
HRESULT CMapToken::QueryInterface(REFIID riid, void **ppUnk)
{
- *ppUnk = 0;
+ if (ppUnk == NULL)
+ return E_INVALIDARG;
+
+ if (IsEqualIID(riid, IID_IMapToken))
+ {
+ *ppUnk = (IMapToken *) this;
+ }
+ else if (IsEqualIID(riid, IID_IUnknown))
+ {
+ *ppUnk = (IUnknown *) this;
+ }
+ else
+ {
+ *ppUnk = NULL;
+ return (E_NOINTERFACE);
+ }
- if (riid == IID_IMapToken)
- *ppUnk = (IUnknown *) (IMapToken *) this;
- else
- return (E_NOINTERFACE);
AddRef();
return (S_OK);
} // CMapToken::QueryInterface