summaryrefslogtreecommitdiff
path: root/cli/ops/dispatch_json.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-10-25 19:23:16 +0200
committerRy Dahl <ry@tinyclouds.org>2019-10-25 13:23:16 -0400
commitdfcdc0315233019740d76448be68cad0292a6c1d (patch)
tree68be63c092cdfe1d8ac9bcf04c5cfe3a05e4f691 /cli/ops/dispatch_json.rs
parent2270abbc448c31c958d78ec55714392f77c13472 (diff)
fix: handle malformed control buffers (#3202)
Diffstat (limited to 'cli/ops/dispatch_json.rs')
-rw-r--r--cli/ops/dispatch_json.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/ops/dispatch_json.rs b/cli/ops/dispatch_json.rs
index 3a8faf2a8..5f1caac6f 100644
--- a/cli/ops/dispatch_json.rs
+++ b/cli/ops/dispatch_json.rs
@@ -48,7 +48,13 @@ where
D: Fn(Value, Option<PinnedBuf>) -> Result<JsonOp, ErrBox>,
{
move |control: &[u8], zero_copy: Option<PinnedBuf>| {
- let async_args: AsyncArgs = serde_json::from_slice(control).unwrap();
+ let async_args: AsyncArgs = match serde_json::from_slice(control) {
+ Ok(args) => args,
+ Err(e) => {
+ let buf = serialize_result(None, Err(ErrBox::from(e)));
+ return CoreOp::Sync(buf);
+ }
+ };
let promise_id = async_args.promise_id;
let is_sync = promise_id.is_none();