aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-07-07 22:52:58 +0000
committerChong Yidong2009-07-07 22:52:58 +0000
commit0f3f018c34072e19975fdb647f7f7eb7838dabbe (patch)
treec08bcdf54b958e877fa5859c03688be600edc365
parent69a197a214dbb33415af772dc87b5e8ae3f553f2 (diff)
downloademacs-0f3f018c34072e19975fdb647f7f7eb7838dabbe.tar.gz
emacs-0f3f018c34072e19975fdb647f7f7eb7838dabbe.zip
* fileio.c (Fsubstitute_in_file_name, Ffile_name_directory)
(Fexpand_file_name): Copy string data properly (Bug#3772).
-rw-r--r--src/ChangeLog5
-rw-r--r--src/fileio.c16
2 files changed, 14 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a072f49cb8d..d9ff8b1dfd2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12009-07-07 Chong Yidong <cyd@stupidchicken.com>
2
3 * fileio.c (Fsubstitute_in_file_name, Ffile_name_directory)
4 (Fexpand_file_name): Copy string data properly (Bug#3772).
5
12009-07-07 Jan Djärv <jan.h.d@swipnet.se> 62009-07-07 Jan Djärv <jan.h.d@swipnet.se>
2 7
3 * xterm.c (handle_one_xevent): Only call x_check_fullscreen on the 8 * xterm.c (handle_one_xevent): Only call x_check_fullscreen on the
diff --git a/src/fileio.c b/src/fileio.c
index ed5c09bc840..bf96b3aa2b1 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -422,9 +422,11 @@ Given a Unix syntax file name, returns a string ending in slash. */)
422 return call2 (handler, Qfile_name_directory, filename); 422 return call2 (handler, Qfile_name_directory, filename);
423 423
424 filename = FILE_SYSTEM_CASE (filename); 424 filename = FILE_SYSTEM_CASE (filename);
425 beg = SDATA (filename);
426#ifdef DOS_NT 425#ifdef DOS_NT
427 beg = strcpy (alloca (strlen (beg) + 1), beg); 426 beg = (unsigned char *) alloca (SBYTES (filename) + 1);
427 bcopy (SDATA (filename), beg, SBYTES (filename) + 1);
428#else
429 beg = SDATA (filename);
428#endif 430#endif
429 p = beg + SBYTES (filename); 431 p = beg + SBYTES (filename);
430 432
@@ -939,10 +941,9 @@ filesystem tree, not (expand-file-name ".." dirname). */)
939 } 941 }
940 } 942 }
941 943
942 nm = SDATA (name);
943
944 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ 944 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
945 nm = strcpy (alloca (strlen (nm) + 1), nm); 945 nm = (unsigned char *) alloca (SBYTES (name) + 1);
946 bcopy (SDATA (name), nm, SBYTES (name) + 1);
946 947
947#ifdef DOS_NT 948#ifdef DOS_NT
948 /* Note if special escape prefix is present, but remove for now. */ 949 /* Note if special escape prefix is present, but remove for now. */
@@ -1641,11 +1642,12 @@ those `/' is discarded. */)
1641 if (!NILP (handler)) 1642 if (!NILP (handler))
1642 return call2 (handler, Qsubstitute_in_file_name, filename); 1643 return call2 (handler, Qsubstitute_in_file_name, filename);
1643 1644
1644 nm = SDATA (filename);
1645 /* Always work on a copy of the string, in case GC happens during 1645 /* Always work on a copy of the string, in case GC happens during
1646 decode of environment variables, causing the original Lisp_String 1646 decode of environment variables, causing the original Lisp_String
1647 data to be relocated. */ 1647 data to be relocated. */
1648 nm = strcpy (alloca (strlen (nm) + 1), nm); 1648 nm = (unsigned char *) alloca (SBYTES (filename) + 1);
1649 bcopy (SDATA (filename), nm, SBYTES (filename) + 1);
1650
1649#ifdef DOS_NT 1651#ifdef DOS_NT
1650 CORRECT_DIR_SEPS (nm); 1652 CORRECT_DIR_SEPS (nm);
1651 substituted = (strcmp (nm, SDATA (filename)) != 0); 1653 substituted = (strcmp (nm, SDATA (filename)) != 0);