From bcfcafdb7ce27f0ee47fc55f753b9f9c7ff0eb0e Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 6 Jun 2013 00:39:31 +0200 Subject: [PATCH] tty: Use calloc() instead of malloc() to prevent uninitialized errors. On some platforms GCC does not zero the heap. This can lead to serious problems, e.g., tty->pid may be non-zero while never having been started. Signed-off-by: Joachim Nilsson --- tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tty.c b/tty.c index 21ede70f..72fb0765 100644 --- a/tty.c +++ b/tty.c @@ -71,7 +71,7 @@ int tty_register(char *line) entry = tty_find(dev); if (!entry) { insert = 1; - entry = malloc(sizeof(*entry)); + entry = calloc(1, sizeof(*entry)); if (!entry) return errno = ENOMEM; }