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
47
47
48
48
#[ instrument]
49
49
pub ( crate ) async fn get_process_infos ( ) -> common:: Result < ProcessInfos > {
50
- let buffer_size =
50
+ let buffer_size_sign =
51
51
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 {
53
53
return Err ( io:: Error :: last_os_error ( ) . into ( ) ) ;
54
54
}
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] ;
56
63
let result = unsafe {
57
64
libproc:: proc_listpids (
58
65
libproc:: PROC_ALL_PIDS ,
59
66
0_u32 ,
60
67
buffer. as_mut_ptr ( ) . cast ( ) ,
61
- buffer_size ,
68
+ buffer_size_sign ,
62
69
)
63
70
} ;
64
71
if result <= 0 {
You can’t perform that action at this time.
0 commit comments