diff options
author | Koundinya Veluri <kouvel@microsoft.com> | 2017-05-09 13:56:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-09 13:56:40 -0700 |
commit | c8a37801f8483d05766e0bf053ffa41aaa155f2c (patch) | |
tree | 8e01a17aa262b0779668b845069bd57d2d50d67b /src/md | |
parent | 39a841c33a6ae70cc887ee9fa7cfdeb834c6ca59 (diff) | |
download | coreclr-c8a37801f8483d05766e0bf053ffa41aaa155f2c.tar.gz coreclr-c8a37801f8483d05766e0bf053ffa41aaa155f2c.tar.bz2 coreclr-c8a37801f8483d05766e0bf053ffa41aaa155f2c.zip |
Fix static analysis issues (#11466)
Fix static analysis issues
Diffstat (limited to 'src/md')
-rw-r--r-- | src/md/ceefilegen/cceegen.cpp | 30 | ||||
-rw-r--r-- | src/md/enc/mdinternalrw.cpp | 2 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/md/ceefilegen/cceegen.cpp b/src/md/ceefilegen/cceegen.cpp index 0cf0780d15..bd69c8daed 100644 --- a/src/md/ceefilegen/cceegen.cpp +++ b/src/md/ceefilegen/cceegen.cpp @@ -38,22 +38,30 @@ HRESULT STDMETHODCALLTYPE CreateICeeGen(REFIID riid, void **pCeeGen) HRESULT CCeeGen::CreateNewInstance(CCeeGen* & pGen) // static, public { - pGen = new CCeeGen(); - _ASSERTE(pGen != NULL); - TESTANDRETURNMEMORY(pGen); + NewHolder<CCeeGen> pGenHolder(new CCeeGen()); + _ASSERTE(pGenHolder != NULL); + TESTANDRETURNMEMORY(pGenHolder); - pGen->m_peSectionMan = new PESectionMan; - _ASSERTE(pGen->m_peSectionMan != NULL); - TESTANDRETURNMEMORY(pGen->m_peSectionMan); + pGenHolder->m_peSectionMan = new PESectionMan; + _ASSERTE(pGenHolder->m_peSectionMan != NULL); + TESTANDRETURNMEMORY(pGenHolder->m_peSectionMan); - HRESULT hr = pGen->m_peSectionMan->Init(); - TESTANDRETURNHR(hr); + HRESULT hr = pGenHolder->m_peSectionMan->Init(); + if (FAILED(hr)) + { + pGenHolder->Cleanup(); + return hr; + } - hr = pGen->Init(); - TESTANDRETURNHR(hr); + hr = pGenHolder->Init(); + if (FAILED(hr)) + { + // Init() calls Cleanup() on failure + return hr; + } + pGen = pGenHolder.Extract(); return hr; - } STDMETHODIMP CCeeGen::QueryInterface(REFIID riid, void** ppv) diff --git a/src/md/enc/mdinternalrw.cpp b/src/md/enc/mdinternalrw.cpp index 02fb407358..75c793967e 100644 --- a/src/md/enc/mdinternalrw.cpp +++ b/src/md/enc/mdinternalrw.cpp @@ -2393,7 +2393,7 @@ HRESULT MDInternalRW::GetItemGuid( // return hresult // Get the GUID, if any. hr = GetCustomAttributeByName(tkObj, INTEROP_GUID_TYPE, (const void**)&pBlob, &cbBlob); - if (hr != S_FALSE) + if (SUCCEEDED(hr) && hr != S_FALSE) { // Should be in format. Total length == 41 // <0x0001><0x24>01234567-0123-0123-0123-001122334455<0x0000> |