From 6eaadcc7c821b7a8c75ce6d1d56cd7f50898f809 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 10 Dec 2016 15:36:11 +0100 Subject: [PATCH] Treat incomplete integer literals as errors See Bug#25120. * src/lread.c (read_integer): Treat incomplete integer literals as errors. * test/src/lread-tests.el (lread-empty-int-literal): New unit test for incomplete integer literals. --- src/lread.c | 2 +- test/src/lread-tests.el | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lread.c b/src/lread.c index fdbf0329118..35348f1ddb8 100644 --- a/src/lread.c +++ b/src/lread.c @@ -2536,7 +2536,7 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix) *p = '\0'; } - if (! valid) + if (valid != 1) { sprintf (buf, "integer, radix %"pI"d", radix); invalid_syntax (buf); diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 1a82d133a44..609f82ec20b 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -104,4 +104,12 @@ (ert-deftest lread-string-char-name () (should (equal (read "\"a\\N{SYLOTI NAGRI LETTER DHO}b\"") "a\uA817b"))) +(ert-deftest lread-empty-int-literal () + "Check that Bug#25120 is fixed." + (should-error (read "#b") :type 'invalid-read-syntax) + (should-error (read "#o") :type 'invalid-read-syntax) + (should-error (read "#x") :type 'invalid-read-syntax) + (should-error (read "#24r") :type 'invalid-read-syntax) + (should-error (read "#") :type 'invalid-read-syntax)) + ;;; lread-tests.el ends here -- 2.39.2