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

Commit e7ecf35

Browse files
committed
Fix one of DCS constructors that cause NRE in wcf
1 parent 4c423dc commit e7ecf35

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public DataContractSerializer(Type type, string rootName, string rootNamespace)
5050

5151
public DataContractSerializer(Type type, string rootName, string rootNamespace, IEnumerable<Type> knownTypes)
5252
{
53-
Initialize(type, new XmlDictionaryString(null, rootName, 0), new XmlDictionaryString(null, rootNamespace, 0), knownTypes, int.MaxValue, false, false, null, false);
53+
XmlDictionary dictionary = new XmlDictionary(2);
54+
Initialize(type, dictionary.Add(rootName), dictionary.Add(DataContract.GetNamespace(rootNamespace)), knownTypes, int.MaxValue, false, false, null, false);
5455
}
5556

5657

src/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class XmlDictionaryString
2626
public XmlDictionaryString(IXmlDictionary dictionary, string value, int key)
2727
{
2828
if (dictionary == null)
29-
_dictionary = new EmptyStringDictionary();
29+
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("dictionary"));
3030
if (value == null)
3131
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value"));
3232
if (key < MinKey || key > MaxKey)

0 commit comments

Comments
 (0)