diff --git a/ChangeLog b/ChangeLog index 3bf62e09..9275aab6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ CVS code - +- files.c: + real_dir_from_tilde() + - Oops, fix case where buf ="~", silly crash (bug discovered by + Neil Parks). nano 0.9.25 - 01/07/2001 General - diff --git a/files.c b/files.c index c5974174..f6656311 100644 --- a/files.c +++ b/files.c @@ -589,11 +589,15 @@ char *real_dir_from_tilde(char *buf) if (buf[0] == '~') { if (buf[1] == '~') goto abort; /* Handle ~~ without segfaulting =) */ - else if (buf[1] == '/') { + else if (buf[1] == 0 || buf[1] == '/') { if (getenv("HOME") != NULL) { dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME"))); - sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]); + if (strlen(buf) > 2) + sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]); + else + sprintf(dirtmp, "%s/", getenv("HOME")); + } } else if (buf[1] != 0) {