mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
38ee85d000
commit
ca292c9768
@ -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 {
|
||||
|
@ -1575,7 +1575,9 @@ static char *shada_filename(const char *file)
|
||||
do { \
|
||||
const String s_ = (s); \
|
||||
msgpack_pack_bin(spacker, s_.size); \
|
||||
msgpack_pack_bin_body(spacker, s_.data, s_.size); \
|
||||
if (s_.size > 0) { \
|
||||
msgpack_pack_bin_body(spacker, s_.data, s_.size); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/// Write single ShaDa entry
|
||||
|
Loading…
Reference in New Issue
Block a user