rust: migration: validate termination of subsection arrays
For consistency with fields(), validate the value (at least to some extent) before passing it to C. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
64bce66d6f
commit
5b4fa97807
1 changed files with 3 additions and 0 deletions
|
|
@ -675,6 +675,9 @@ impl<T> VMStateDescriptionBuilder<T> {
|
|||
|
||||
#[must_use]
|
||||
pub const fn subsections(mut self, subs: &'static VMStateSubsections) -> Self {
|
||||
if subs[subs.len() - 1].is_some() {
|
||||
panic!("subsections are not terminated, use vmstate_subsections!");
|
||||
}
|
||||
let subs: *const Option<&bindings::VMStateDescription> = subs.as_ptr();
|
||||
self.0.subsections = subs.cast::<*const bindings::VMStateDescription>();
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue