Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free temporary enums on failure #50471

Merged
merged 2 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/coreclr/md/compiler/assemblymd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ STDMETHODIMP RegMeta::EnumExportedTypes( // S_OK or error
BEGIN_ENTRYPOINT_NOTHROW;

HENUMInternal **ppmdEnum = reinterpret_cast<HENUMInternal **> (phEnum);
HENUMInternal *pEnum;
HENUMInternal *pEnum = NULL;

LOG((LOGMD, "MD RegMeta::EnumExportedTypes(%#08x, %#08x, %#08x, %#08x)\n",
phEnum, rExportedTypes, cMax, pcTokens));
Expand Down Expand Up @@ -488,14 +488,14 @@ STDMETHODIMP RegMeta::EnumExportedTypes( // S_OK or error

// set the output parameter.
*ppmdEnum = pEnum;
pEnum = NULL;
}
else
pEnum = *ppmdEnum;

// we can only fill the minimum of what the caller asked for or what we have left.
IfFailGo(HENUMInternal::EnumWithCount(pEnum, cMax, rExportedTypes, pcTokens));
IfFailGo(HENUMInternal::EnumWithCount(*ppmdEnum, cMax, rExportedTypes, pcTokens));
ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);

STOP_MD_PERF(EnumExportedTypes);
END_ENTRYPOINT_NOTHROW;
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/md/compiler/custattr_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ STDMETHODIMP RegMeta::EnumCustomAttributes(
HENUMInternal **ppmdEnum = reinterpret_cast<HENUMInternal **> (phEnum);
RID ridStart;
RID ridEnd;
HENUMInternal *pEnum = *ppmdEnum;
HENUMInternal *pEnum = NULL;
CustomAttributeRec *pRec;
ULONG index;

Expand All @@ -117,7 +117,7 @@ STDMETHODIMP RegMeta::EnumCustomAttributes(
START_MD_PERF();
LOCKREAD();

if ( pEnum == 0 )
if ( *ppmdEnum == 0 )
{
// instantiating a new ENUM
CMiniMdRW *pMiniMd = &(m_pStgdb->m_MiniMd);
Expand Down Expand Up @@ -220,13 +220,15 @@ STDMETHODIMP RegMeta::EnumCustomAttributes(

// set the output parameter
*ppmdEnum = pEnum;
pEnum = NULL;
}

// fill the output token buffer
hr = HENUMInternal::EnumWithCount(pEnum, cMax, rCustomAttributes, pcCustomAttributes);
hr = HENUMInternal::EnumWithCount(*ppmdEnum, cMax, rCustomAttributes, pcCustomAttributes);

ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);

STOP_MD_PERF(EnumCustomAttributes);
END_ENTRYPOINT_NOTHROW;
Expand Down
Loading