mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
msgpack-rpc: handle failure to convert method arguments #2664
This commit is contained in:
@@ -464,7 +464,11 @@ static void handle_request(Channel *channel, msgpack_object *request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
msgpack_rpc_to_array(msgpack_rpc_args(request), &args);
|
if (!msgpack_rpc_to_array(msgpack_rpc_args(request), &args)) {
|
||||||
|
handler.fn = msgpack_rpc_handle_invalid_arguments;
|
||||||
|
handler.defer = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool defer = (!kv_size(channel->call_stack) && handler.defer);
|
bool defer = (!kv_size(channel->call_stack) && handler.defer);
|
||||||
RequestEvent *event_data = xmalloc(sizeof(RequestEvent));
|
RequestEvent *event_data = xmalloc(sizeof(RequestEvent));
|
||||||
event_data->channel = channel;
|
event_data->channel = channel;
|
||||||
|
@@ -306,6 +306,17 @@ Object msgpack_rpc_handle_missing_method(uint64_t channel_id,
|
|||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handler executed when malformated arguments are passed
|
||||||
|
Object msgpack_rpc_handle_invalid_arguments(uint64_t channel_id,
|
||||||
|
uint64_t request_id,
|
||||||
|
Array args,
|
||||||
|
Error *error)
|
||||||
|
{
|
||||||
|
snprintf(error->msg, sizeof(error->msg), "Invalid method arguments");
|
||||||
|
error->set = true;
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
|
||||||
/// Serializes a msgpack-rpc request or notification(id == 0)
|
/// Serializes a msgpack-rpc request or notification(id == 0)
|
||||||
void msgpack_rpc_serialize_request(uint64_t request_id,
|
void msgpack_rpc_serialize_request(uint64_t request_id,
|
||||||
String method,
|
String method,
|
||||||
|
Reference in New Issue
Block a user