diff options
| author | Mattias EngdegÄrd | 2022-07-08 15:09:16 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-07-08 15:13:21 +0200 |
| commit | 6791165b2a0e707f719efec08aad62cdf6ed8ad3 (patch) | |
| tree | d98f464114aa6b60c7fa8156e26e3edb9a019585 /src | |
| parent | 739e3dbe050468e1d9aa0a48bfc656ae20fd8f9d (diff) | |
| download | emacs-6791165b2a0e707f719efec08aad62cdf6ed8ad3.tar.gz emacs-6791165b2a0e707f719efec08aad62cdf6ed8ad3.zip | |
Fix file-name-case-insensitive-p in ffap (bug#56443)
Don't crash if the file name argument to file-name-case-insensitive-p,
after expansion, doesn't have a parent directory. This occurs
when calling ffap on something that looks like an email address.
* src/fileio.c (Ffile_name_case_insensitive_p): Return nil if no file
or parent directory could be found.
* test/src/fileio-tests.el (fileio-tests--identity-expand-handler)
(fileio--file-name-case-insensitive-p): New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fileio.c b/src/fileio.c index d07e62a1212..9697f6c8cf1 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2601,9 +2601,9 @@ is case-insensitive. */) | |||
| 2601 | if (err <= 0) | 2601 | if (err <= 0) |
| 2602 | return err < 0 ? Qt : Qnil; | 2602 | return err < 0 ? Qt : Qnil; |
| 2603 | Lisp_Object parent = file_name_directory (filename); | 2603 | Lisp_Object parent = file_name_directory (filename); |
| 2604 | /* Avoid infinite loop if the root has trouble | 2604 | /* Avoid infinite loop if the root has trouble (if that's even possible). |
| 2605 | (impossible?). */ | 2605 | Without a parent, we just don't know and return nil as well. */ |
| 2606 | if (!NILP (Fstring_equal (parent, filename))) | 2606 | if (!STRINGP (parent) || !NILP (Fstring_equal (parent, filename))) |
| 2607 | return Qnil; | 2607 | return Qnil; |
| 2608 | filename = parent; | 2608 | filename = parent; |
| 2609 | } | 2609 | } |