Avoid serializing NULL string through msgpack

Attempting to serialize a NULL string through msgpack results in
msgpack_sbuffer_write attempting to memcpy from a NULL pointer, which is
undefined behavior.
This commit is contained in:
James McCoy
2016-11-17 18:16:46 -05:00
parent 38ee85d000
commit ca292c9768
2 changed files with 6 additions and 2 deletions

View File

@@ -326,7 +326,9 @@ void msgpack_rpc_from_string(String result, msgpack_packer *res)
FUNC_ATTR_NONNULL_ARG(2)
{
msgpack_pack_str(res, result.size);
msgpack_pack_str_body(res, result.data, result.size);
if (result.size > 0) {
msgpack_pack_str_body(res, result.data, result.size);
}
}
typedef struct {