-
Notifications
You must be signed in to change notification settings - Fork 915
Closed
Description
Describe the bug
msgpack-cxx 7.0.0 throws an exception when writing an empty string using fbuffer.
The exception is thrown at the following if statement.
msgpack-c/include/msgpack/v1/fbuffer.hpp
Lines 34 to 36 in 9b801f0
| if (1 != fwrite(buf, len, 1, m_file)) { | |
| throw std::runtime_error("fwrite() failed"); | |
| } |
To Reproduce
I ran the following using msgpack-cxx 7.0.0 and Clang 19.1.7.
#include <cstdio>
#include <msgpack.hpp>
#include <msgpack/fbuffer.hpp>
int main() {
std::FILE* file = std::fopen("test_error_in_msgpack.data", "wb");
if (file == nullptr) {
std::perror("Failed to open file");
return 1;
}
msgpack::fbuffer buffer(file);
msgpack::packer<msgpack::fbuffer> packer(buffer);
packer.pack(std::string());
return 0;
}Expected behavior
No exception should happen.
Metadata
Metadata
Assignees
Labels
No labels