]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid race in rcirc process filter (bug#33145)
authorBasil L. Contovounesios <contovob@tcd.ie>
Thu, 25 Oct 2018 02:35:57 +0000 (03:35 +0100)
committerEli Zaretskii <eliz@gnu.org>
Sat, 3 Nov 2018 08:46:01 +0000 (10:46 +0200)
* lisp/net/rcirc.el (rcirc-filter): Clear rcirc-process-output
before processing its constituent lines.  Otherwise, if rcirc-filter
runs again before the last rcirc-process-server-response is
finished, the contents of rcirc-process-output could be duplicated.

lisp/net/rcirc.el

index c09bff765b22992d90766809bf0abeb419a37c0b..f57f7555c32fd7e411caa63e3a67c79591e8d33e 100644 (file)
@@ -753,12 +753,12 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
   (with-rcirc-process-buffer process
     (setq rcirc-last-server-message-time (current-time))
     (setq rcirc-process-output (concat rcirc-process-output output))
-    (when (= (aref rcirc-process-output
-                   (1- (length rcirc-process-output))) ?\n)
-      (mapc (lambda (line)
-              (rcirc-process-server-response process line))
-            (split-string rcirc-process-output "[\n\r]" t))
-      (setq rcirc-process-output nil))))
+    (when (= ?\n (aref rcirc-process-output
+                       (1- (length rcirc-process-output))))
+      (let ((lines (split-string rcirc-process-output "[\n\r]" t)))
+        (setq rcirc-process-output nil)
+        (dolist (line lines)
+          (rcirc-process-server-response process line))))))
 
 (defun rcirc-reschedule-timeout (process)
   (with-rcirc-process-buffer process