-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullReferenceException in XmlObjectSerializerReadContext.ReplaceDeserializedObject #41465
Comments
eerhardt
added a commit
to eerhardt/runtime
that referenced
this issue
Aug 27, 2020
krwq
pushed a commit
that referenced
this issue
Aug 28, 2020
…Runtime.Serialization.Json (#41476) * Initial nullable annotations of System.Private.DataContractSerialization Contributes to #2339 * Mark DataMember.Name as non-nullable. * Fix a few simple nullable compile errors. * Assert attributes is non-null in XmlObjectSerializerReadContext * Ensure XmlObjectSerializerContext.serializer is never null * Fix a few simple nullable errors * Remove any checks that DataMember.MemberInfo can be null. * Mark EnumDataContract.Members as non-nullable. Fix nullable errors in SchemaExporter. * Correctly annotate CollectionDataContract.IsCollectionOrTryCreate. * Assert DataContractResolver is non-null. * Suppress #41465 * Update System.Runtime.Serialization.Json ref source for nullable annotations. * Update System.Runtime.Serializaiton.Xml ref source for nullable annotations. * Update for Xml.ReaderWriter nullable annotations * Work around compiler issue. * Fix test failure. Reference compiler issue in TODO comment. * Revert nullable suppression now that XmlSchemaAppInfo.Markup is annotated correctly. * Fix build for latest annotations in master. * PR feedback round 1 * Address PR feedback round 2
carlossanlop
pushed a commit
to carlossanlop/runtime
that referenced
this issue
Aug 28, 2020
…Runtime.Serialization.Json (dotnet#41476) * Initial nullable annotations of System.Private.DataContractSerialization Contributes to dotnet#2339 * Mark DataMember.Name as non-nullable. * Fix a few simple nullable compile errors. * Assert attributes is non-null in XmlObjectSerializerReadContext * Ensure XmlObjectSerializerContext.serializer is never null * Fix a few simple nullable errors * Remove any checks that DataMember.MemberInfo can be null. * Mark EnumDataContract.Members as non-nullable. Fix nullable errors in SchemaExporter. * Correctly annotate CollectionDataContract.IsCollectionOrTryCreate. * Assert DataContractResolver is non-null. * Suppress dotnet#41465 * Update System.Runtime.Serialization.Json ref source for nullable annotations. * Update System.Runtime.Serializaiton.Xml ref source for nullable annotations. * Update for Xml.ReaderWriter nullable annotations * Work around compiler issue. * Fix test failure. Reference compiler issue in TODO comment. * Revert nullable suppression now that XmlSchemaAppInfo.Markup is annotated correctly. * Fix build for latest annotations in master. * PR feedback round 1 * Address PR feedback round 2
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It is possible for
null
objects to be passed toXmlObjectSerializerReadContext.ReplaceDeserializedObject
:runtime/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs
Lines 400 to 416 in 6072e4d
The
throw
statement de-references the objects to callGetType()
on them in order to log their types in the exception message. However, I can't find anything that ensures both of these parameters are non-null. If they are both null, the method exits early, but if one of them is null, it might be possible for this to throwNullReferenceException
.Of the 3 callers of this method, only 1 of them has the potential to pass in
null
:runtime/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContextComplex.cs
Lines 115 to 127 in aa5fdab
I can reproduce the NullReferenceException with the following code and .xml file:
Exception
The text was updated successfully, but these errors were encountered: