Skip to content

Commit 6399c31

Browse files
committed
ensure param slot exists
1 parent 14fb44e commit 6399c31

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

phper/src/values.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl ExecuteData {
209209
}
210210
}
211211

212-
pub unsafe fn get_parameters_array(&mut self) -> Vec<ManuallyDrop<ZVal>> {
212+
pub(crate) unsafe fn get_parameters_array(&mut self) -> Vec<ManuallyDrop<ZVal>> {
213213
unsafe {
214214
let num_args = self.num_args();
215215
let mut arguments = vec![zeroed::<zval>(); num_args];
@@ -238,6 +238,18 @@ impl ExecuteData {
238238
ZVal::from_mut_ptr(val)
239239
}
240240
}
241+
242+
/// Ensure parameter slot exists, if not, create it and set to null.
243+
pub fn ensure_parameter_slot(&mut self, index: usize) {
244+
let num_args = self.num_args();
245+
if index >= num_args {
246+
unsafe {
247+
let params_ptr = phper_zend_call_var_num(self.as_mut_ptr(), index as i32);
248+
phper_zval_null(params_ptr);
249+
(*self.inner.func).common.num_args = (index + 1) as u32;
250+
}
251+
}
252+
}
241253
}
242254

243255
/// Wrapper of [zval].

0 commit comments

Comments
 (0)