From bfd0544471f7214087b36d9f72acdcc6c1cadd4a Mon Sep 17 00:00:00 2001 From: dickmao Date: Sat, 7 Aug 2021 11:50:53 -0400 Subject: [PATCH] Forestall "Selected deleted buffer" in url-http-generic-filter As 93e1248 is more circumspect about cleaning up process buffers, network streams *qua* processes, which get cleaned up on a timetable independent of conventional processes, may find the rug pulled out from under them. * lisp/url/url-http.el (url-http-generic-filter): Check that corresponding buffer is still live. --- lisp/url/url-http.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index e3c178630a..ba13a17a8f 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -1494,17 +1494,18 @@ url-http-generic-filter ;; Sometimes we get a zero-length data chunk after the process has ;; been changed to 'free', which means it has no buffer associated ;; with it. Do nothing if there is no buffer, or 0 length data. - (and (process-buffer proc) - (/= (length data) 0) - (with-current-buffer (process-buffer proc) - (url-http-debug "Calling after change function `%s' for `%S'" url-http-after-change-function proc) - (funcall url-http-after-change-function - (point-max) - (progn - (goto-char (point-max)) - (insert data) - (point-max)) - (length data))))) + (let ((b (process-buffer proc))) + (when (and (buffer-live-p b) (not (zerop (length data)))) + (with-current-buffer b + (url-http-debug "Calling after change function `%s' for `%S'" + url-http-after-change-function proc) + (funcall url-http-after-change-function + (point-max) + (progn + (goto-char (point-max)) + (insert data) + (point-max)) + (length data)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; file-name-handler stuff from here on out -- 2.26.2