If the first realloc() call fails then 'd' becomes NULL,
subsequent realloc() retries will behave like malloc() and
the the original src pointer is never freed. Further more
the newly allocated data then contains uninitialized data
where the previous pids had been stored.
Avoid this by passing the the original pointer from '*src'
to realloc().
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
*asz = BUF_RESERVE_SIZE;
} else if (tmplen + *sz + 1 >= *asz) {
do {
- d = realloc(d, *asz + BUF_RESERVE_SIZE);
+ d = realloc(*src, *asz + BUF_RESERVE_SIZE);
} while (!d);
*src = d;
*asz += BUF_RESERVE_SIZE;