From 37b3b5a5ed91cbcaa6aa37185448735e849a060c Mon Sep 17 00:00:00 2001 From: dantok Date: Sun, 25 Jan 2015 20:48:02 +0100 Subject: [PATCH] Fix an edge case when obtaining home directory. Make the path to home directory empty before calling get_home_dir(), otherwise if the call fails, the contents are undefined. --- src/autocomplete.c | 1 + src/configdir.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/autocomplete.c b/src/autocomplete.c index 1c7c94b..982879a 100644 --- a/src/autocomplete.c +++ b/src/autocomplete.c @@ -210,6 +210,7 @@ static void complt_home_dir(ToxWindow *self, char *path, int pathsize, const cha ChatContext *ctx = self->chatwin; char homedir[MAX_STR_SIZE]; + homedir[0] = '\0'; get_home_dir(homedir, sizeof(homedir)); char newline[MAX_STR_SIZE]; diff --git a/src/configdir.c b/src/configdir.c index 9bc6744..a8f4b85 100644 --- a/src/configdir.c +++ b/src/configdir.c @@ -67,6 +67,7 @@ void get_home_dir(char *home, int size) char *get_user_config_dir(void) { char home[NSS_BUFLEN_PASSWD]; + home[0] = '\0'; get_home_dir(home, sizeof(home)); char *user_config_dir;