File tree 2 files changed +9
-8
lines changed
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -403,18 +403,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
403
403
404
404
let epfd = this. read_scalar ( epfd) ?. to_i32 ( ) ?;
405
405
let maxevents = this. read_scalar ( maxevents) ?. to_i32 ( ) ?;
406
- let event = this. deref_pointer_as (
407
- events_op,
408
- this. libc_array_ty_layout ( "epoll_event" , maxevents. try_into ( ) . unwrap ( ) ) ,
409
- ) ?;
410
406
let timeout = this. read_scalar ( timeout) ?. to_i32 ( ) ?;
411
-
412
407
if epfd <= 0 || maxevents <= 0 {
413
408
let einval = this. eval_libc ( "EINVAL" ) ;
414
409
this. set_last_error ( einval) ?;
415
410
return Ok ( Scalar :: from_i32 ( -1 ) ) ;
416
411
}
417
412
413
+ // This needs to come after the maxevents value check, or else maxevents.try_into().unwrap()
414
+ // will fail.
415
+ let event = this. deref_pointer_as (
416
+ events_op,
417
+ this. libc_array_ty_layout ( "epoll_event" , maxevents. try_into ( ) . unwrap ( ) ) ,
418
+ ) ?;
419
+
418
420
// FIXME: Implement blocking support
419
421
if timeout != 0 {
420
422
throw_unsup_format ! ( "epoll_wait: timeout value can only be 0" ) ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ fn main() {
19
19
test_epoll_ctl_del ( ) ;
20
20
test_pointer ( ) ;
21
21
test_two_same_fd_in_same_epoll_instance ( ) ;
22
- test_epoll_wait_less_maxevent_zero ( ) ;
22
+ test_epoll_wait_maxevent_zero ( ) ;
23
23
}
24
24
25
25
// Using `as` cast since `EPOLLET` wraps around
@@ -530,8 +530,7 @@ fn test_no_notification_for_unregister_flag() {
530
530
check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
531
531
}
532
532
533
-
534
- fn test_epoll_wait_less_maxevent_zero ( ) {
533
+ fn test_epoll_wait_maxevent_zero ( ) {
535
534
// Create an epoll instance.
536
535
let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
537
536
assert_ne ! ( epfd, -1 ) ;
You can’t perform that action at this time.
0 commit comments