fix memory safety hole around borrow

This commit is contained in:
Jorge Aparicio 2017-04-13 22:57:06 -05:00
parent 692ad81ad8
commit 2fb00c7d85
3 changed files with 25 additions and 27 deletions

View file

@ -64,12 +64,15 @@ where
/// section
///
/// This operation is zero cost and doesn't impose any additional blocking
pub fn borrow<'cs, SCEILING>(
pub fn borrow<'cs, PRIORITY, SCEILING>(
&'static self,
_priority: &P<PRIORITY>,
_system_ceiling: &'cs C<SCEILING>,
) -> &'cs T
where
SCEILING: GreaterThanOrEqual<CEILING>,
CEILING: GreaterThanOrEqual<PRIORITY>,
P<PRIORITY>: Priority,
{
unsafe { &*self.data.get() }
}
@ -216,12 +219,14 @@ where
C<CEILING>: Ceiling,
{
/// See [Resource.borrow](./struct.Resource.html#method.borrow)
pub fn borrow<'cs, SCEILING>(
pub fn borrow<'cs, PRIORITY, SCEILING>(
&'static self,
_priority: &P<PRIORITY>,
_system_ceiling: &'cs C<SCEILING>,
) -> &'cs Periph
where
SCEILING: GreaterThanOrEqual<CEILING>,
CEILING: GreaterThanOrEqual<PRIORITY>,
{
unsafe { &*self.peripheral.get() }
}