summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/interact.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/source3/utils/interact.c b/source3/utils/interact.c
index 39ec707176..6d753dd012 100644
--- a/source3/utils/interact.c
+++ b/source3/utils/interact.c
@@ -31,16 +31,19 @@
#include <termios.h>
static const char* get_editor(void) {
- static const char* editor = NULL;
- if (editor == NULL) {
- editor = getenv("VISUAL");
- if (editor == NULL) {
- editor = getenv("EDITOR");
+ static char editor[64] = {0};
+
+ if (editor[0] == '\0') {
+ const char *tmp = getenv("VISUAL");
+ if (tmp == NULL) {
+ tmp = getenv("EDITOR");
}
- if (editor == NULL) {
- editor = "vi";
+ if (tmp == NULL) {
+ tmp = "vi";
}
+ snprintf(editor, sizeof(editor), "%s", tmp);
}
+
return editor;
}