File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
crates/libs/kill_tree/src Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,25 @@ pub(crate) async fn get_process_info(process_id: ProcessId) -> Option<ProcessInf
4747
4848#[ instrument]
4949pub ( crate ) async fn get_process_infos ( ) -> common:: Result < ProcessInfos > {
50- let buffer_size =
50+ let buffer_size_sign =
5151 unsafe { libproc:: proc_listpids ( libproc:: PROC_ALL_PIDS , 0_u32 , ptr:: null_mut ( ) , 0 ) } ;
52- if buffer_size <= 0 {
52+ if buffer_size_sign <= 0 {
5353 return Err ( io:: Error :: last_os_error ( ) . into ( ) ) ;
5454 }
55- let mut buffer = vec ! [ 0 ; buffer_size as usize ] ;
55+ let buffer_size = match usize:: try_from ( buffer_size_sign) {
56+ Ok ( x) => x,
57+ Err ( e) => {
58+ debug ! ( error = ?e, "failed to convert buffer size" ) ;
59+ return Err ( e. into ( ) ) ;
60+ }
61+ } ;
62+ let mut buffer = vec ! [ 0 ; buffer_size] ;
5663 let result = unsafe {
5764 libproc:: proc_listpids (
5865 libproc:: PROC_ALL_PIDS ,
5966 0_u32 ,
6067 buffer. as_mut_ptr ( ) . cast ( ) ,
61- buffer_size ,
68+ buffer_size_sign ,
6269 )
6370 } ;
6471 if result <= 0 {
You can’t perform that action at this time.
0 commit comments