diff options
| author | Dmitry Gutov | 2024-06-11 05:54:57 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2024-06-11 05:54:57 +0300 |
| commit | bac8a70f454d022d8352200d85eacd27017d4f12 (patch) | |
| tree | e420c7d4dbf077807123d0a4a7f61749c87949ed /src | |
| parent | d9890bb87063b402853ff0e4ea8bbfc92e5d6e00 (diff) | |
| download | emacs-bac8a70f454d022d8352200d85eacd27017d4f12.tar.gz emacs-bac8a70f454d022d8352200d85eacd27017d4f12.zip | |
fast-read-process-output: Make safer
* src/process.c (read_process_output): Move the call to
'read_and_insert_process_output' from here.
(read_and_dispose_of_process_output): To here (bug#66020). So
that any Lisp code invoked through modification hook from the
former function also benefit from safety guards like
running_asynch_code, saved match data, inhibit_quot, etc.
Diffstat (limited to 'src')
| -rw-r--r-- | src/process.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/process.c b/src/process.c index 60264d367b8..b6ec114e2b3 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -6263,10 +6263,7 @@ read_process_output (Lisp_Object proc, int channel) | |||
| 6263 | friends don't expect current-buffer to be changed from under them. */ | 6263 | friends don't expect current-buffer to be changed from under them. */ |
| 6264 | record_unwind_current_buffer (); | 6264 | record_unwind_current_buffer (); |
| 6265 | 6265 | ||
| 6266 | if (fast_read_process_output && EQ (p->filter, Qinternal_default_process_filter)) | 6266 | read_and_dispose_of_process_output (p, chars, nbytes, coding); |
| 6267 | read_and_insert_process_output (p, chars, nbytes, coding); | ||
| 6268 | else | ||
| 6269 | read_and_dispose_of_process_output (p, chars, nbytes, coding); | ||
| 6270 | 6267 | ||
| 6271 | /* Handling the process output should not deactivate the mark. */ | 6268 | /* Handling the process output should not deactivate the mark. */ |
| 6272 | Vdeactivate_mark = odeactivate; | 6269 | Vdeactivate_mark = odeactivate; |
| @@ -6479,19 +6476,27 @@ read_and_dispose_of_process_output (struct Lisp_Process *p, char *chars, | |||
| 6479 | save the match data in a special nonrecursive fashion. */ | 6476 | save the match data in a special nonrecursive fashion. */ |
| 6480 | running_asynch_code = 1; | 6477 | running_asynch_code = 1; |
| 6481 | 6478 | ||
| 6482 | decode_coding_c_string (coding, (unsigned char *) chars, nbytes, Qt); | 6479 | if (fast_read_process_output && EQ (p->filter, Qinternal_default_process_filter)) |
| 6483 | text = coding->dst_object; | 6480 | { |
| 6481 | read_and_insert_process_output (p, chars, nbytes, coding); | ||
| 6482 | } | ||
| 6483 | else | ||
| 6484 | { | ||
| 6485 | decode_coding_c_string (coding, (unsigned char *) chars, nbytes, Qt); | ||
| 6486 | text = coding->dst_object; | ||
| 6484 | 6487 | ||
| 6485 | read_process_output_set_last_coding_system (p, coding); | 6488 | read_process_output_set_last_coding_system (p, coding); |
| 6486 | 6489 | ||
| 6487 | if (SBYTES (text) > 0) | 6490 | if (SBYTES (text) > 0) |
| 6488 | /* FIXME: It's wrong to wrap or not based on debug-on-error, and | 6491 | /* FIXME: It's wrong to wrap or not based on debug-on-error, and |
| 6489 | sometimes it's simply wrong to wrap (e.g. when called from | 6492 | sometimes it's simply wrong to wrap (e.g. when called from |
| 6490 | accept-process-output). */ | 6493 | accept-process-output). */ |
| 6491 | internal_condition_case_1 (read_process_output_call, | 6494 | internal_condition_case_1 (read_process_output_call, |
| 6492 | list3 (outstream, make_lisp_proc (p), text), | 6495 | list3 (outstream, make_lisp_proc (p), text), |
| 6493 | !NILP (Vdebug_on_error) ? Qnil : Qerror, | 6496 | !NILP (Vdebug_on_error) ? Qnil : Qerror, |
| 6494 | read_process_output_error_handler); | 6497 | read_process_output_error_handler); |
| 6498 | |||
| 6499 | } | ||
| 6495 | 6500 | ||
| 6496 | /* If we saved the match data nonrecursively, restore it now. */ | 6501 | /* If we saved the match data nonrecursively, restore it now. */ |
| 6497 | restore_search_regs (); | 6502 | restore_search_regs (); |