diff options
| author | Philipp Stephani | 2018-04-15 23:45:27 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-04-15 23:50:06 -0700 |
| commit | 9f2d21ca536ea7ca1da98e7bd57ae535ab394997 (patch) | |
| tree | cc40bd68be4070f926852a8129f3d84ccb6bd86c | |
| parent | 836dce63c3274eaa84a26c09a5b6dcb1522dba98 (diff) | |
| download | emacs-9f2d21ca536ea7ca1da98e7bd57ae535ab394997.tar.gz emacs-9f2d21ca536ea7ca1da98e7bd57ae535ab394997.zip | |
Avoid undefined behavior in 'defvar' (Bug#31072)
* src/eval.c (Fdefvar): Check that first argument is a symbol.
* test/src/eval-tests.el (defvar/bug31072): New unit test.
| -rw-r--r-- | src/eval.c | 2 | ||||
| -rw-r--r-- | test/src/eval-tests.el | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index a6e1d86c4ab..90d8c335185 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -737,6 +737,8 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) | |||
| 737 | sym = XCAR (args); | 737 | sym = XCAR (args); |
| 738 | tail = XCDR (args); | 738 | tail = XCDR (args); |
| 739 | 739 | ||
| 740 | CHECK_SYMBOL (sym); | ||
| 741 | |||
| 740 | if (!NILP (tail)) | 742 | if (!NILP (tail)) |
| 741 | { | 743 | { |
| 742 | if (!NILP (XCDR (tail)) && !NILP (XCDR (XCDR (tail)))) | 744 | if (!NILP (XCDR (tail)) && !NILP (XCDR (XCDR (tail)))) |
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index 59da6b7cc30..319dd91c86a 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -113,4 +113,8 @@ crash/abort/malloc assert failure on the next test." | |||
| 113 | (signal-hook-function #'ignore)) | 113 | (signal-hook-function #'ignore)) |
| 114 | (should-error (eval-tests--exceed-specbind-limit)))) | 114 | (should-error (eval-tests--exceed-specbind-limit)))) |
| 115 | 115 | ||
| 116 | (ert-deftest defvar/bug31072 () | ||
| 117 | "Check that Bug#31072 is fixed." | ||
| 118 | (should-error (eval '(defvar 1) t) :type 'wrong-type-argument)) | ||
| 119 | |||
| 116 | ;;; eval-tests.el ends here | 120 | ;;; eval-tests.el ends here |