]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: fix memory leak of empty readline() string
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 12 Feb 2025 12:22:04 +0000 (13:22 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 12 Feb 2025 14:41:10 +0000 (15:41 +0100)
client.c

index 70bcdae24e11e1dabfac40e055b78bd2846d34e2..6bbce140e77c0448d6a87b4a9aabd7566cf5c869 100644 (file)
--- 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);