policycoreutils: sandbox: seunshare: do not reassign realloc value

We were doing x = realloc(x, )  which is a big no no, since it leaks X
on allocation failure.  Found with static analysis tool from David
Malcolm.

Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Eric Paris 2013-02-01 15:23:12 -05:00
parent 709e852aed
commit 0a5dc30456
1 changed files with 4 additions and 1 deletions

View File

@ -774,10 +774,13 @@ killall (security_context_t execcon)
continue; continue;
if (pids == max_pids) { if (pids == max_pids) {
if (!(pid_table = realloc(pid_table, 2*pids*sizeof(pid_t)))) { pid_t *new_pid_table = realloc(pid_table, 2*pids*sizeof(pid_t));
if (!new_pid_table) {
free(pid_table);
(void)closedir(dir); (void)closedir(dir);
return -1; return -1;
} }
pid_table = new_pid_table;
max_pids *= 2; max_pids *= 2;
} }
pid_table[pids++] = pid; pid_table[pids++] = pid;