From 0c437eb48ab75570510898837bf7e95ce4c7dae5 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Tue, 7 Jul 2009 22:26:41 +0000 Subject: [PATCH] * fileio.c (Fsubstitute_in_file_name): Copy string data properly. --- src/ChangeLog | 4 ++++ src/fileio.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 12015414fe7..ab1501af211 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-07-07 Chong Yidong + + * fileio.c (Fsubstitute_in_file_name): Copy string data properly. + 2009-07-07 Kenichi Handa * .gdbinit (xcharset): Fix the treating of $arg0. diff --git a/src/fileio.c b/src/fileio.c index ed5c09bc840..8529455071f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1641,11 +1641,12 @@ those `/' is discarded. */) if (!NILP (handler)) return call2 (handler, Qsubstitute_in_file_name, filename); - nm = SDATA (filename); /* Always work on a copy of the string, in case GC happens during decode of environment variables, causing the original Lisp_String data to be relocated. */ - nm = strcpy (alloca (strlen (nm) + 1), nm); + nm = (unsigned char *) alloca (SBYTES (filename) + 1); + bcopy (SDATA (filename), nm, SBYTES (filename) + 1); + #ifdef DOS_NT CORRECT_DIR_SEPS (nm); substituted = (strcmp (nm, SDATA (filename)) != 0); -- 2.39.2