From 43023fa51913b5f15a7e33275e3787c46ff74cc1 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 7 Oct 2015 09:25:04 +0100 Subject: [PATCH] 0 initialize strings Otherwise bad things happen when you strcat into them. Oops. Signed-off-by: Dirk Hohndel --- linux.c | 2 +- macos.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux.c b/linux.c index d82e77436..d23af1aa0 100644 --- a/linux.c +++ b/linux.c @@ -86,7 +86,7 @@ const char *system_default_filename(void) const char *user = getenv("LOGNAME"); if (same_string(user, "")) user = "username"; - filename = malloc(strlen(user) + 5); + filename = calloc(strlen(user) + 5, 1); strcat(filename, user); strcat(filename, ".xml"); } diff --git a/macos.c b/macos.c index 09589cc82..aa2be4b3b 100644 --- a/macos.c +++ b/macos.c @@ -79,7 +79,7 @@ const char *system_default_filename(void) const char *user = getenv("LOGNAME"); if (same_string(user, "")) user = "username"; - filename = malloc(strlen(user) + 5); + filename = calloc(strlen(user) + 5, 1); strcat(filename, user); strcat(filename, ".xml"); }