yalishandar / tasklist-rs

Get the process name or process id on windows
19 stars 3 forks source link

thread 'main' panicked at 'range end index 27690 out of range for slice of length 10000' #1

Open webnoob opened 1 year ago

webnoob commented 1 year ago

Hi,

I'm getting the following error:

thread 'main' panicked at 'range end index 27690 out of range for slice of length 10000', C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tasklist-0.2.12\src\infos\info.rs:393:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[0524/140042.139:ERROR:window_impl.cc(119)] Failed to unregister class Chrome_WidgetWin_0. Error = 0

when running:

#[cfg(windows)] {
        let tl = tasklist::Tasklist::new();
        for i in tl {
          let s = tasklist::get_proc_params(i.get_pid());
        }
}

(obviously a cut down version of my code). Commenting out let s = tasklist::get_proc_params(i.get_pid()); stops the panick.

I can see why the error happens, looking at the file:

let mut temp:[u16;10000] = [0;10000];

The array size is hardcoded and doesn't allow enough

yalishandar commented 1 year ago

Sorry, there are some flaws in the code. I will update these errors in my spare time. If you have copied these codes, you can also submit pr.