Commit bf692615 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

real_dir_from_tilde(): ops, fix case where buf =~, silly crash

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 7e08082f
Showing with 10 additions and 2 deletions
+10 -2
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 -
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment