mirror of https://github.com/xzeldon/htop.git
Ensure buffer for environment is large enough on NetBSD
This commit is contained in:
parent
0388b30077
commit
4f1269cc9f
|
@ -311,7 +311,13 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||||
for (char** p = ptr; *p; p++) {
|
for (char** p = ptr; *p; p++) {
|
||||||
size_t len = strlen(*p) + 1;
|
size_t len = strlen(*p) + 1;
|
||||||
|
|
||||||
if (size + len > capacity) {
|
while (size + len > capacity) {
|
||||||
|
if (capacity > (SIZE_MAX / 2)) {
|
||||||
|
free(env);
|
||||||
|
env = NULL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
capacity *= 2;
|
capacity *= 2;
|
||||||
env = xRealloc(env, capacity);
|
env = xRealloc(env, capacity);
|
||||||
}
|
}
|
||||||
|
@ -327,6 +333,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||||
env[size + 1] = 0;
|
env[size + 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
(void) kvm_close(kt);
|
(void) kvm_close(kt);
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue