chrony/backport-fix-memory-leak-of-empty-readline-string.patch

33 lines
889 B
Diff
Raw Normal View History

2025-04-15 06:22:01 +00:00
From 55898e9b07d2bf97cb3bb96987dbe57f1b6376ef Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed, 12 Feb 2025 13:22:04 +0100
Subject: [PATCH] client: fix memory leak of empty readline() string
Conflict:NA
Reference:https://github.com/mlichvar/chrony/commit/55898e9b07d2bf97cb3bb96987dbe57f1b6376ef
---
client.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/client.c b/client.c
index 70bcdae..6bbce14 100644
--- a/client.c
+++ b/client.c
@@ -125,12 +125,11 @@ read_line(void)
strncpy(line, cmd, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
add_history(cmd);
- /* free the buffer allocated by readline */
- Free(cmd);
} else {
/* simulate the user has entered an empty line */
*line = '\0';
}
+ Free(cmd);
return( line );
#else
printf("%s", prompt);
--
2.33.0