X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/89077ebcc8990c84d94a601b221210d3ff7a8ec7..9f104fbfce353d62694ea0b191b186e5467dc916:/src/msw/registry.cpp diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 9ab127dd67..099b376cfd 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -427,6 +427,18 @@ bool wxRegKey::DeleteSelf() } } + // prevent a buggy program from erasing one of the root registry keys or an + // immediate subkey (i.e. one which doesn't have '\\' inside) of any other + // key except HKCR (HKCR has some "deleteable" subkeys) + if ( m_strKey.IsEmpty() || (m_hRootKey != HKCR && + m_strKey.Find(REG_SEPARATOR) == wxNOT_FOUND) ) { + wxLogError(_("Registry key '%s' is needed for normal system operation,\n" + "deleting it will leave your system in unusable state:\n" + "operation aborted."), GetFullName(this)); + + return FALSE; + } + // we can't delete keys while enumerating because it confuses GetNextKey, so // we first save the key names and then delete them all wxArrayString astrSubkeys; @@ -776,6 +788,21 @@ bool wxRegKey::GetNextKey(wxString& strKeyName, long& lIndex) const return TRUE; } +// returns TRUE if the value contains a number (else it's some string) +bool wxRegKey::IsNumericValue(const char *szValue) const + { + ValueType type = GetValueType(szValue); + switch ( type ) { + case Type_Dword: + case Type_Dword_little_endian: + case Type_Dword_big_endian: + return TRUE; + + default: + return FALSE; + } + } + // ============================================================================ // implementation of global private functions // ============================================================================