2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 21:07:18 +00:00

Merge pull request #2999 from rikardfalkeborn/fix-realloc-memleak-proctitle

initutils: Fix memleak on realloc failure
This commit is contained in:
Christian Brauner
2019-05-13 13:19:55 +02:00
committed by GitHub

View File

@@ -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;