Skip to content

Commit 93f96dc

Browse files
committed
Validate input to C2CPlan::c2c and R2RPlan::r2r
The underlying C function requires that the arrays passed into it have the same length and alignment as was used to create the plan. Adding this check prevents out-of-bounds reads and possibly writes. The same check is already in place for C2R and R2C plans. Fixes: 3e84ddd Fixes: 862fead
1 parent acdb209 commit 93f96dc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fftw/src/plan.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ macro_rules! impl_c2c {
202202
})
203203
}
204204
fn c2c(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Complex]) -> Result<()> {
205+
self.check(in_, out)?;
205206
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
206207
Ok(())
207208
}
@@ -315,6 +316,7 @@ macro_rules! impl_r2r {
315316
})
316317
}
317318
fn r2r(&mut self, in_: &mut [Self::Real], out: &mut [Self::Real]) -> Result<()> {
319+
self.check(in_, out)?;
318320
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
319321
Ok(())
320322
}

0 commit comments

Comments
 (0)