Code52/DownmarkerWPF — pull request #348 by imgen (2012-12-02 07:06:46+00:00)
Title: Fix startup crash issue with a NullReference exception

The code
private static bool Enabled(string s, RegistryKey key, RegistryKey openSubKey)
{
return openSubKey != null &&
(key.GetSubKeyNames().Contains(s) &&
!string.IsNullOrEmpty(openSubKey.GetValue("").ToString()));
}
is causing startup crash with a NullReference excpetion if openSubKey.GetValue("") returns null. So the correct code should be
private static bool Enabled(string s, RegistryKey key, RegistryKey openSubKey)
{
object defaultNameValue = openSubKey.GetValue(null);
string defaultNameValueAsString = defaultNameValue == null ? null : defaultNameValue.ToString();
return openSubKey != null &&
(key.GetSubKeyNames().Contains(s) &&
!string.IsNullOrEmpty(defaultNameValueAsString));
}