Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix resource lookup recusrion issue (#13948)
Browse files Browse the repository at this point in the history
  • Loading branch information
safern authored Sep 13, 2017
1 parent ae51536 commit 0ddcf7e
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/mscorlib/src/System/Globalization/CultureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,25 @@ public CultureInfo(String name, bool useUserOverride) {
this.m_isInherited = (this.GetType() != typeof(System.Globalization.CultureInfo));
}

private CultureInfo(CultureData cultureData)
{
Contract.Assert(cultureData != null);
m_cultureData = cultureData;
m_name = cultureData.CultureName;
m_isInherited = false;
}

private static CultureInfo CreateCultureInfoNoThrow(string name, bool useUserOverride)
{
Contract.Assert(name != null);
CultureData cultureData = CultureData.GetCultureData(name, useUserOverride);
if (cultureData == null)
{
return null;
}

return new CultureInfo(cultureData);
}

#if FEATURE_USE_LCID
public CultureInfo(int culture) : this(culture, true) {
Expand Down Expand Up @@ -926,25 +945,22 @@ public virtual CultureInfo Parent

if (null == m_parent)
{
try
{
string parentName = this.m_cultureData.SPARENT;
string parentName = this.m_cultureData.SPARENT;

if (String.IsNullOrEmpty(parentName))
if (String.IsNullOrEmpty(parentName))
{
m_parent = InvariantCulture;
}
else
{
m_parent = CreateCultureInfoNoThrow(parentName, m_cultureData.UseUserOverride);
if (m_parent == null)
{
// For whatever reason our IPARENT or SPARENT wasn't correct, so use invariant
// We can't allow ourselves to fail. In case of custom cultures the parent of the
// current custom culture isn't installed.
m_parent = InvariantCulture;
}
else
{
m_parent = new CultureInfo(parentName, this.m_cultureData.UseUserOverride);
}
}
catch (ArgumentException)
{
// For whatever reason our IPARENT or SPARENT wasn't correct, so use invariant
// We can't allow ourselves to fail. In case of custom cultures the parent of the
// current custom culture isn't installed.
m_parent = InvariantCulture;
}
}
return m_parent;
Expand Down

0 comments on commit 0ddcf7e

Please sign in to comment.