mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-24 19:36:52 +03:00
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
This commit is contained in:
parent
7e08082ffe
commit
bf69261597
@ -1,4 +1,8 @@
|
|||||||
CVS code -
|
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
|
nano 0.9.25 - 01/07/2001
|
||||||
General -
|
General -
|
||||||
|
8
files.c
8
files.c
@ -589,11 +589,15 @@ char *real_dir_from_tilde(char *buf)
|
|||||||
if (buf[0] == '~') {
|
if (buf[0] == '~') {
|
||||||
if (buf[1] == '~')
|
if (buf[1] == '~')
|
||||||
goto abort; /* Handle ~~ without segfaulting =) */
|
goto abort; /* Handle ~~ without segfaulting =) */
|
||||||
else if (buf[1] == '/') {
|
else if (buf[1] == 0 || buf[1] == '/') {
|
||||||
if (getenv("HOME") != NULL) {
|
if (getenv("HOME") != NULL) {
|
||||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
|
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) {
|
} else if (buf[1] != 0) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user