From d764cfae1a0953fc9225c367c7cb93a02fb19293 Mon Sep 17 00:00:00 2001 From: Jon Hanna Date: Sun, 20 Dec 2015 14:12:39 +0000 Subject: [PATCH] Null Check on JsonWriter.WriteToken Fixes #752 --- Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs | 10 ++++++++++ Src/Newtonsoft.Json/JsonWriter.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs index d92681b8..5309b2a6 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs @@ -897,6 +897,16 @@ Parameter name: value"); } } + [Test] + public void WriteTokenNullCheck() + { + using (JsonWriter jsonWriter = new JsonTextWriter(new StringWriter())) + { + ExceptionAssert.Throws(() => { jsonWriter.WriteToken(null); }); + ExceptionAssert.Throws(() => { jsonWriter.WriteToken(null, true); }); + } + } + [Test] public void BadWriteEndArray() { diff --git a/Src/Newtonsoft.Json/JsonWriter.cs b/Src/Newtonsoft.Json/JsonWriter.cs index a6bc5342..942569bb 100644 --- a/Src/Newtonsoft.Json/JsonWriter.cs +++ b/Src/Newtonsoft.Json/JsonWriter.cs @@ -483,7 +483,7 @@ namespace Newtonsoft.Json /// The to read the token from. public void WriteToken(JsonReader reader) { - WriteToken(reader, true, true, true); + WriteToken(reader, true); } ///