From 9ebfb37f98fc2f17b97763838c17b18dd396dc68 Mon Sep 17 00:00:00 2001 From: Eugene Rozenfeld Date: Thu, 10 Mar 2016 13:05:23 -0800 Subject: [PATCH] Fix for a bug in GetCORSystemDirectoryInternaL Change 7045ca7a6de381b382a709dc0a61f49ca713d160 introduced a bug in GetCORSystemDirectoryInternaL. The second parameter of GetRuntimeDirectory is in/out so passing a pointer to an uninitialized cchBuffer was wrong. The fix is to initialize cchBuffer to MAX_PATH - 1. This was causing failures in some non CoreClr ngen scenarios. --- src/dlls/mscoree/mscoree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dlls/mscoree/mscoree.cpp b/src/dlls/mscoree/mscoree.cpp index d42733a..74d3f97 100644 --- a/src/dlls/mscoree/mscoree.cpp +++ b/src/dlls/mscoree/mscoree.cpp @@ -941,13 +941,13 @@ STDAPI GetCORSystemDirectoryInternaL(SString& pBuffer) return hr; #else // FEATURE_CORECLR || CROSSGEN_COMPILE - DWORD cchBuffer; + DWORD cchBuffer = MAX_PATH - 1; // Simply forward the call to the ICLRRuntimeInfo implementation. STATIC_CONTRACT_WRAPPER; HRESULT hr = S_OK; if (g_pCLRRuntime) { - WCHAR* temp = pBuffer.OpenUnicodeBuffer(MAX_PATH - 1); + WCHAR* temp = pBuffer.OpenUnicodeBuffer(cchBuffer); hr = g_pCLRRuntime->GetRuntimeDirectory(temp, &cchBuffer); pBuffer.CloseBuffer(cchBuffer - 1); } -- 2.7.4