diff --git a/src/coreclr/nativeaot/Runtime/RhConfig.cpp b/src/coreclr/nativeaot/Runtime/RhConfig.cpp index af6d130bd7dde9..283fe09e3b8fd3 100644 --- a/src/coreclr/nativeaot/Runtime/RhConfig.cpp +++ b/src/coreclr/nativeaot/Runtime/RhConfig.cpp @@ -56,7 +56,14 @@ bool RhConfig::Environment::TryGetIntegerValue(const char* name, uint64_t* value // Environment variable was set. Convert it to an integer. uint64_t uiResult = 0; - for (uint32_t i = 0; i < cchResult; i++) + uint32_t startIndex = 0; + if (!decimal && cchResult >= 2 && buffer[0] == '0' && (buffer[1] == 'x' || buffer[1] == 'X')) + { + startIndex = 2; + if (startIndex == cchResult) + return false; // parse error - hex prefix without any digits + } + for (uint32_t i = startIndex; i < cchResult; i++) { TCHAR ch = buffer[i];