Skip to content

Commit 01bb817

Browse files
committed
fix: check both name of the fields are identical
+ compare length of the maps to ensure no extra args
1 parent f4bcd81 commit 01bb817

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

clarity/src/vm/clarity_wasm.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,9 +1571,14 @@ fn get_required_bytes(ty: &TypeSignature, value: &Value) -> Result<usize, Error>
15711571
};
15721572

15731573
let mut total_bytes = 0;
1574-
let type_map = tuple_ty.get_type_map();
1575-
for (value, ty) in data_map.values().zip(type_map.values()) {
1576-
total_bytes += get_required_bytes(ty, value)?;
1574+
for (name, ty) in tuple_ty.get_type_map() {
1575+
match data_map.get(name) {
1576+
Some(value) => total_bytes += get_required_bytes(ty, value)?,
1577+
None => return Err(Error::Wasm(WasmError::ValueTypeMismatch)),
1578+
}
1579+
}
1580+
if data_map.len() != tuple_ty.get_type_map().len() {
1581+
return Err(Error::Wasm(WasmError::ValueTypeMismatch));
15771582
}
15781583
Ok(total_bytes)
15791584
}

0 commit comments

Comments
 (0)