# HG changeset patch # User Chong Yidong # Date 1247007178 0 # Node ID 41dca7756517bd0f32fbb758d537d0d92293e7d6 # Parent a1a6e341fa6e3744b5aa34e1b06c68e135c726d7 * fileio.c (Fsubstitute_in_file_name, Ffile_name_directory) (Fexpand_file_name): Copy string data properly (Bug#3772). diff -r a1a6e341fa6e -r 41dca7756517 src/ChangeLog --- a/src/ChangeLog Tue Jul 07 20:10:05 2009 +0000 +++ b/src/ChangeLog Tue Jul 07 22:52:58 2009 +0000 @@ -1,3 +1,8 @@ +2009-07-07 Chong Yidong + + * fileio.c (Fsubstitute_in_file_name, Ffile_name_directory) + (Fexpand_file_name): Copy string data properly (Bug#3772). + 2009-07-07 Jan Djärv * xterm.c (handle_one_xevent): Only call x_check_fullscreen on the diff -r a1a6e341fa6e -r 41dca7756517 src/fileio.c --- a/src/fileio.c Tue Jul 07 20:10:05 2009 +0000 +++ b/src/fileio.c Tue Jul 07 22:52:58 2009 +0000 @@ -422,9 +422,11 @@ return call2 (handler, Qfile_name_directory, filename); filename = FILE_SYSTEM_CASE (filename); +#ifdef DOS_NT + beg = (unsigned char *) alloca (SBYTES (filename) + 1); + bcopy (SDATA (filename), beg, SBYTES (filename) + 1); +#else beg = SDATA (filename); -#ifdef DOS_NT - beg = strcpy (alloca (strlen (beg) + 1), beg); #endif p = beg + SBYTES (filename); @@ -939,10 +941,9 @@ } } - nm = SDATA (name); - /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ - nm = strcpy (alloca (strlen (nm) + 1), nm); + nm = (unsigned char *) alloca (SBYTES (name) + 1); + bcopy (SDATA (name), nm, SBYTES (name) + 1); #ifdef DOS_NT /* Note if special escape prefix is present, but remove for now. */ @@ -1641,11 +1642,12 @@ 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);