[PATCH 29/34] agetty: fix memory leak [clang-analyzer]

Sami Kerola
2013-07-07T19:56:25Z

term-utils/agetty.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 054a1dd..5a75433 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -463,9 +463,11 @@ static char *replace_u(char *str, char *username)
}
sz = strlen(str);

- if (p == str && sz == 2)
+ if (p == str && sz == 2) {
/* 'str' contains only '\u' */
+ free(old);
return username;
+ }

tp = entry = malloc(sz + usz);
if (!tp)
--
1.8.3.2