From: Dmitry Bogatov <KAction@debian.org>
Date: Mon, 12 Aug 2019 23:26:46 +0000
Subject: Fix uninitialized variable error

If stat(2) in `rc_access', statbuf is left uninitialized, but still used in
conditional.

Detected with valgrind.

Updated to avoid crash in tab completion,
details in https://bugs.debian.org/1004645.

Forwarded: https://github.com/rakitzis/rc/pull/56
---
 edit-readline.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/edit-readline.c b/edit-readline.c
index 47c8db5..8a9d0fa 100644
--- a/edit-readline.c
+++ b/edit-readline.c
@@ -116,7 +116,14 @@ static char *entry(char *dname, char *name, char *subdirs,
 		efree(full);
 		return maybe_quote(dir_join(subdirs, name));
 	}
+	
+	if (stat(full, &st) != 0) {
+		goto null;
+	}
+
 	efree(full);
+	full = NULL;
+
 	if (S_ISDIR(st.st_mode)) {
 		char *dir_ret = ealloc(strlen(name) + 5);
 		char *r;
@@ -128,6 +135,8 @@ static char *entry(char *dname, char *name, char *subdirs,
 		efree(dir_ret);
 		return maybe_quote(r);
 	}
+null:
+	efree(full);
 	return NULL;
 }
 
