aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2018-12-19 13:42:21 -0800
committerPaul Eggert2018-12-19 13:42:47 -0800
commitf4ea7464516b22409f429e98595b97cbf8220f4c (patch)
tree8b48a82e1d3c11ce7629e553df614ec453ec332a
parentfda43a7bef499024fa5fcb32432e76c5839ee154 (diff)
downloademacs-f4ea7464516b22409f429e98595b97cbf8220f4c.tar.gz
emacs-f4ea7464516b22409f429e98595b97cbf8220f4c.zip
cl-make-random-state was not copying its arg
Problem reported by Xu Chunyang (Bug#33731). * lisp/emacs-lisp/cl-extra.el (cl-make-random-state): Use copy-sequence, not copy-tree, so that the record is copied. * test/lisp/emacs-lisp/cl-extra-tests.el: (cl-extra-test-cl-make-random-state): New test.
-rw-r--r--lisp/emacs-lisp/cl-extra.el2
-rw-r--r--test/lisp/emacs-lisp/cl-extra-tests.el5
2 files changed, 6 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 36b65f97b07..c38b4957fc7 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -484,7 +484,7 @@ Optional second arg STATE is a random-state object."
484If STATE is t, return a new state object seeded from the time of day." 484If STATE is t, return a new state object seeded from the time of day."
485 (unless state (setq state cl--random-state)) 485 (unless state (setq state cl--random-state))
486 (if (cl-random-state-p state) 486 (if (cl-random-state-p state)
487 (copy-tree state t) 487 (copy-sequence state)
488 (cl--make-random-state (if (integerp state) state (cl--random-time))))) 488 (cl--make-random-state (if (integerp state) state (cl--random-time)))))
489 489
490;; Implementation limits. 490;; Implementation limits.
diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el
index baad8eb8e67..fe59703530f 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -94,4 +94,9 @@
94 (should (equal (list lst3 (cdr lst3) (cddr lst3)) 94 (should (equal (list lst3 (cdr lst3) (cddr lst3))
95 (cl-maplist fn3 lst lst2 lst3))))) 95 (cl-maplist fn3 lst lst2 lst3)))))
96 96
97(ert-deftest cl-extra-test-cl-make-random-state ()
98 (let ((s (cl-make-random-state)))
99 ;; Test for Bug#33731.
100 (should-not (eq s (cl-make-random-state s)))))
101
97;;; cl-extra-tests.el ends here 102;;; cl-extra-tests.el ends here