diff --git a/include/rapidjson/stream.h b/include/rapidjson/stream.h index dd2783b41..fef82c252 100644 --- a/include/rapidjson/stream.h +++ b/include/rapidjson/stream.h @@ -95,7 +95,7 @@ inline void PutUnsafe(Stream& stream, typename Stream::Ch c) { //! Put N copies of a character to a stream. template inline void PutN(Stream& stream, Ch c, size_t n) { - PutReserve(stream, n); + PutReserve(stream, n); for (size_t i = 0; i < n; i++) PutUnsafe(stream, c); } diff --git a/test/unittest/stringbuffertest.cpp b/test/unittest/stringbuffertest.cpp index 9be98fce2..ded513cdd 100644 --- a/test/unittest/stringbuffertest.cpp +++ b/test/unittest/stringbuffertest.cpp @@ -37,6 +37,13 @@ TEST(StringBuffer, Put) { EXPECT_STREQ("A", buffer.GetString()); } +TEST(StringBuffer, PutN_Issue672) { + GenericStringBuffer, MemoryPoolAllocator<> > buffer; + EXPECT_EQ(0, buffer.GetSize()); + rapidjson::PutN(buffer, ' ', 1); + EXPECT_EQ(1, buffer.GetSize()); +} + TEST(StringBuffer, Clear) { StringBuffer buffer; buffer.Put('A');