This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 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> {
403403
404404 let epfd = this. read_scalar ( epfd) ?. to_i32 ( ) ?;
405405 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- ) ?;
410406 let timeout = this. read_scalar ( timeout) ?. to_i32 ( ) ?;
411-
412407 if epfd <= 0 || maxevents <= 0 {
413408 let einval = this. eval_libc ( "EINVAL" ) ;
414409 this. set_last_error ( einval) ?;
415410 return Ok ( Scalar :: from_i32 ( -1 ) ) ;
416411 }
417412
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+
418420 // FIXME: Implement blocking support
419421 if timeout != 0 {
420422 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() {
1919 test_epoll_ctl_del ( ) ;
2020 test_pointer ( ) ;
2121 test_two_same_fd_in_same_epoll_instance ( ) ;
22- test_epoll_wait_less_maxevent_zero ( ) ;
22+ test_epoll_wait_maxevent_zero ( ) ;
2323}
2424
2525// Using `as` cast since `EPOLLET` wraps around
@@ -530,8 +530,7 @@ fn test_no_notification_for_unregister_flag() {
530530 check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
531531}
532532
533-
534- fn test_epoll_wait_less_maxevent_zero ( ) {
533+ fn test_epoll_wait_maxevent_zero ( ) {
535534 // Create an epoll instance.
536535 let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
537536 assert_ne ! ( epfd, -1 ) ;
You can’t perform that action at this time.
0 commit comments