Properly zero memory where appropriate (bug 14401, bug 14403)

This commit is contained in:
rim
2018-05-26 23:40:11 +02:00
committed by Landry Breuil
parent fa797de140
commit 2329f243fb
6 changed files with 12 additions and 5 deletions

View File

@@ -102,6 +102,7 @@ gboolean get_task_list (GArray *task_list)
#else
struct kinfo_proc2 p = kp[i];
#endif
bzero(&t, sizeof(t));
t.pid = p.p_pid;
t.ppid = p.p_ppid;
t.uid = p.p_uid;
@@ -116,6 +117,7 @@ gboolean get_task_list (GArray *task_list)
size = 128;
if ((args = malloc(size)) == NULL)
errx(1,"failed to allocate memory for argv structures at %zu", size);
bzero(args, size);
for (;; size *= 2) {
if ((args = realloc(args, size)) == NULL)
errx(1,"failed to allocate memory (size=%zu) for argv structures of pid %d", size, t.pid);