[lxc-devel] [lxc/master] initutils: Fix memleak on realloc failure
rikardfalkeborn on Github
lxc-bot at linuxcontainers.org
Sun May 12 00:32:46 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190511/41c21a9c/attachment.bin>
-------------- next part --------------
From 7d07da0e998358620f7ca9600505785dd74f6536 Mon Sep 17 00:00:00 2001
From: Rikard Falkeborn <rikard.falkeborn at gmail.com>
Date: Sun, 12 May 2019 02:22:15 +0200
Subject: [PATCH] initutils: Fix memleak on realloc failure
Signed-off-by: Rikard Falkeborn <rikard.falkeborn at gmail.com>
---
src/lxc/initutils.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c
index a55d8b2860..8b3c2d8307 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);
+ tmp_proctitle = realloc(proctitle, len);
if (!proctitle)
return -1;
+ proctitle = tmp_proctitle;
+
arg_start = (unsigned long)proctitle;
arg_end = arg_start + len;
More information about the lxc-devel
mailing list