Fixed processing of empty data in fbuffer class.

This commit is contained in:
Kenta Kabashima
2025-07-21 22:48:28 +09:00
parent 9b801f087a
commit 6bd9a571f2
2 changed files with 2 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ public:
{ {
MSGPACK_ASSERT(buf || len == 0); MSGPACK_ASSERT(buf || len == 0);
if (!buf) return; if (!buf) return;
if (len == 0) return;
if (1 != fwrite(buf, len, 1, m_file)) { if (1 != fwrite(buf, len, 1, m_file)) {
throw std::runtime_error("fwrite() failed"); throw std::runtime_error("fwrite() failed");
} }

View File

@@ -90,6 +90,7 @@ BOOST_AUTO_TEST_CASE(fbuffer)
fbuf.write("a", 1); fbuf.write("a", 1);
fbuf.write("a", 1); fbuf.write("a", 1);
fbuf.write("a", 1); fbuf.write("a", 1);
fbuf.write("", 0);
fflush(file); fflush(file);
rewind(file); rewind(file);