Merge pull request #1073 from Rantanen/master
Fix null reference error when deserializing bytes
This commit is contained in:
@@ -384,6 +384,14 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
|
|||||||
ExceptionAssert.Throws<JsonReaderException>(() => { reader.ReadAsBytes(); }, "Unexpected end when reading JSON. Path '', line 1, position 1.");
|
ExceptionAssert.Throws<JsonReaderException>(() => { reader.ReadAsBytes(); }, "Unexpected end when reading JSON. Path '', line 1, position 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadBytesEmptyWrappedObject()
|
||||||
|
{
|
||||||
|
JsonTextReader reader = new JsonTextReader(new StringReader(@"{}"));
|
||||||
|
|
||||||
|
ExceptionAssert.Throws<JsonReaderException>(() => { reader.ReadAsBytes(); }, "Error reading bytes. Unexpected token: StartObject. Path '', line 1, position 2." );
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ReadIntegerWithError()
|
public void ReadIntegerWithError()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ namespace Newtonsoft.Json
|
|||||||
internal void ReadIntoWrappedTypeObject()
|
internal void ReadIntoWrappedTypeObject()
|
||||||
{
|
{
|
||||||
ReaderReadAndAssert();
|
ReaderReadAndAssert();
|
||||||
if (Value.ToString() == JsonTypeReflector.TypePropertyName)
|
if (Value != null && Value.ToString() == JsonTypeReflector.TypePropertyName)
|
||||||
{
|
{
|
||||||
ReaderReadAndAssert();
|
ReaderReadAndAssert();
|
||||||
if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal))
|
if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal))
|
||||||
|
|||||||
Reference in New Issue
Block a user