Unverified Commit 22c8f39b by Rikard Falkeborn Committed by Christian Brauner

initutils: Fix memleak on realloc failure

parent 3cd86139
......@@ -242,7 +242,7 @@ int setproctitle(char *title)
{
__do_fclose FILE *f = NULL;
int i, fd, len;
char *buf_ptr;
char *buf_ptr, *tmp_proctitle;
char buf[LXC_LINELEN];
int ret = 0;
ssize_t bytes_read = 0;
......@@ -305,10 +305,12 @@ int setproctitle(char *title)
* want to have room for it. */
len = strlen(title) + 1;
proctitle = realloc(proctitle, len);
if (!proctitle)
tmp_proctitle = realloc(proctitle, len);
if (!tmp_proctitle)
return -1;
proctitle = tmp_proctitle;
arg_start = (unsigned long)proctitle;
arg_end = arg_start + len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment