From a1f8368c23fdc82625282ad606ba48ba0c49b397 Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Gual Date: Wed, 25 Mar 2015 19:40:01 +0100 Subject: [PATCH] Fix stack overflow in RegistryKeyWrapper If OpenSubKey() fails in the WrappedKey property, a RegistryException is thrown. This exception is created using the value of Name as argument, but the Name getter will end making another attempt to open the registry key, which causes and infinite loop and a stack overflow. The solution is to set the _attemptedToOpenRegistryKey flag before trying to get the Name. --- src/XMakeBuildEngine/Utilities/RegistryKeyWrapper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/XMakeBuildEngine/Utilities/RegistryKeyWrapper.cs b/src/XMakeBuildEngine/Utilities/RegistryKeyWrapper.cs index a062fd683c8..d7d9559d59f 100644 --- a/src/XMakeBuildEngine/Utilities/RegistryKeyWrapper.cs +++ b/src/XMakeBuildEngine/Utilities/RegistryKeyWrapper.cs @@ -226,6 +226,7 @@ private RegistryKey WrappedKey if (ExceptionHandling.NotExpectedRegistryException(ex)) throw; + _attemptedToOpenRegistryKey = true; throw new RegistryException(ex.Message, Name, ex); } finally