[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 402cbc5 1/4: Don't rely on copying in {EN,DE}CODE_FILE
From: |
Mattias Engdegård |
Subject: |
master 402cbc5 1/4: Don't rely on copying in {EN,DE}CODE_FILE |
Date: |
Thu, 9 Apr 2020 07:04:08 -0400 (EDT) |
branch: master
commit 402cbc5be26827244075dbe14288e7722290f83a
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Don't rely on copying in {EN,DE}CODE_FILE
Callers of ENCODE_FILE and DECODE_FILE should not assume that these
functions always return a new string (bug#40407).
* src/w32fns.c (Fw32_shell_execute):
* src/w32proc.c (Fw32_application_type):
Sink taking the address of a Lisp string past GC points.
Copy values returned from ENCODE_FILE before mutating them.
---
src/w32fns.c | 4 ++--
src/w32proc.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/w32fns.c b/src/w32fns.c
index 9bb4e27..8d714f0 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -8258,7 +8258,6 @@ a ShowWindow flag:
/* Encode filename, current directory and parameters. */
current_dir = GUI_ENCODE_FILE (current_dir);
document = GUI_ENCODE_FILE (document);
- doc_w = GUI_SDATA (document);
if (STRINGP (parameters))
{
parameters = GUI_ENCODE_SYSTEM (parameters);
@@ -8269,6 +8268,7 @@ a ShowWindow flag:
operation = GUI_ENCODE_SYSTEM (operation);
ops_w = GUI_SDATA (operation);
}
+ doc_w = GUI_SDATA (document);
result = (intptr_t) ShellExecuteW (NULL, ops_w, doc_w, params_w,
GUI_SDATA (current_dir),
(FIXNUMP (show_flag)
@@ -8353,7 +8353,7 @@ a ShowWindow flag:
handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
if (NILP (handler))
{
- Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);
+ Lisp_Object absdoc_encoded = Fcopy_sequence (ENCODE_FILE (absdoc));
if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
{
diff --git a/src/w32proc.c b/src/w32proc.c
index de33726..16e32e4 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -3231,7 +3231,7 @@ such programs cannot be invoked by Emacs anyway. */)
char *progname, progname_a[MAX_PATH];
program = Fexpand_file_name (program, Qnil);
- encoded_progname = ENCODE_FILE (program);
+ encoded_progname = Fcopy_sequence (ENCODE_FILE (program));
progname = SSDATA (encoded_progname);
unixtodos_filename (progname);
filename_to_ansi (progname, progname_a);