From: Rikard Falkeborn Date: Sun, 12 May 2019 00:22:15 +0000 (+0200) Subject: initutils: Fix memleak on realloc failure X-Git-Tag: lxc-3.2.0~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1d43053849d62f15925b343c67cbac2ed7218ba;p=thirdparty%2Flxc.git initutils: Fix memleak on realloc failure Signed-off-by: Rikard Falkeborn --- diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c index a55d8b286..da3363294 100644 --- a/src/lxc/initutils.c +++ b/src/lxc/initutils.c @@ -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;