mirror of https://github.com/xzeldon/htop.git
Fix NULL pointer dereference on kstat_lookup failure
This commit is contained in:
parent
d2c64c16e6
commit
51be2d5415
|
@ -151,24 +151,22 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
|||
}
|
||||
|
||||
int Platform_getMaxPid() {
|
||||
kstat_ctl_t* kc = NULL;
|
||||
kstat_t* kshandle = NULL;
|
||||
kvar_t* ksvar = NULL;
|
||||
int vproc = 32778; // Reasonable Solaris default
|
||||
kc = kstat_open();
|
||||
|
||||
kstat_ctl_t* kc = kstat_open();
|
||||
if (kc != NULL) {
|
||||
kshandle = kstat_lookup(kc, "unix", 0, "var");
|
||||
}
|
||||
kstat_t* kshandle = kstat_lookup(kc, "unix", 0, "var");
|
||||
if (kshandle != NULL) {
|
||||
kstat_read(kc, kshandle, NULL);
|
||||
}
|
||||
ksvar = kshandle->ks_data;
|
||||
if (ksvar->v_proc > 0 ) {
|
||||
|
||||
kvar_t* ksvar = kshandle->ks_data;
|
||||
if (ksvar && ksvar->v_proc > 0) {
|
||||
vproc = ksvar->v_proc;
|
||||
}
|
||||
if (kc != NULL) {
|
||||
}
|
||||
kstat_close(kc);
|
||||
}
|
||||
|
||||
return vproc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue