Add missing data size check.
This commit is contained in:
parent
b9f2fdb635
commit
b86dd3f586
@ -23,6 +23,8 @@ pub struct OpAssignment<'a> {
|
|||||||
/// Hash of the underlying operator call (for fallback).
|
/// Hash of the underlying operator call (for fallback).
|
||||||
pub hash_op: u64,
|
pub hash_op: u64,
|
||||||
/// Op-assignment operator.
|
/// Op-assignment operator.
|
||||||
|
pub op_assign: &'a str,
|
||||||
|
/// Underlying operator.
|
||||||
pub op: &'a str,
|
pub op: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,8 @@ impl OpAssignment<'_> {
|
|||||||
Self {
|
Self {
|
||||||
hash_op_assign: calc_fn_hash(op.literal_syntax(), 2),
|
hash_op_assign: calc_fn_hash(op.literal_syntax(), 2),
|
||||||
hash_op: calc_fn_hash(op_raw, 2),
|
hash_op: calc_fn_hash(op_raw, 2),
|
||||||
op: op.literal_syntax(),
|
op_assign: op.literal_syntax(),
|
||||||
|
op: op_raw,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Create a new [`OpAssignment`] from a base operator.
|
/// Create a new [`OpAssignment`] from a base operator.
|
||||||
|
@ -127,6 +127,7 @@ impl Engine {
|
|||||||
if let Some(OpAssignment {
|
if let Some(OpAssignment {
|
||||||
hash_op_assign,
|
hash_op_assign,
|
||||||
hash_op,
|
hash_op,
|
||||||
|
op_assign,
|
||||||
op,
|
op,
|
||||||
}) = op_info
|
}) = op_info
|
||||||
{
|
{
|
||||||
@ -148,21 +149,23 @@ impl Engine {
|
|||||||
let hash = hash_op_assign;
|
let hash = hash_op_assign;
|
||||||
let args = &mut [lhs_ptr_inner, &mut new_val];
|
let args = &mut [lhs_ptr_inner, &mut new_val];
|
||||||
|
|
||||||
match self.call_native_fn(global, state, lib, op, hash, args, true, true, op_pos) {
|
match self.call_native_fn(
|
||||||
|
global, state, lib, op_assign, hash, args, true, true, op_pos,
|
||||||
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
self.check_data_size(&mut args[0], root.1)?;
|
self.check_data_size(&args[0], root.1)?;
|
||||||
}
|
}
|
||||||
Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, _) if f.starts_with(op)) =>
|
Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, _) if f.starts_with(op_assign)) =>
|
||||||
{
|
{
|
||||||
// Expand to `var = var op rhs`
|
// Expand to `var = var op rhs`
|
||||||
let op = &op[..op.len() - 1]; // extract operator without =
|
|
||||||
|
|
||||||
// Run function
|
|
||||||
let (value, _) = self.call_native_fn(
|
let (value, _) = self.call_native_fn(
|
||||||
global, state, lib, op, hash_op, args, true, false, op_pos,
|
global, state, lib, op, hash_op, args, true, false, op_pos,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "unchecked"))]
|
||||||
|
self.check_data_size(&value, root.1)?;
|
||||||
|
|
||||||
*args[0] = value.flatten();
|
*args[0] = value.flatten();
|
||||||
}
|
}
|
||||||
Err(err) => return Err(err),
|
Err(err) => return Err(err),
|
||||||
|
Loading…
Reference in New Issue
Block a user