From 04a1550cee062b2c3d3b310980a28bf110dd6d20 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Thu, 11 Nov 2021 12:26:59 -0500 Subject: [PATCH] `hex-literal`: ensure '/' as last byte causes error in `hex!()` (#665) --- hex-literal/CHANGELOG.md | 3 +++ hex-literal/src/comments.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/hex-literal/CHANGELOG.md b/hex-literal/CHANGELOG.md index 43edcac4..46e77e34 100644 --- a/hex-literal/CHANGELOG.md +++ b/hex-literal/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - More tests for `hex!()` macro - More internal documentation +### Fixed +- Make `hex!()` error when forward slash encountered as last byte + ## 0.3.3 (2021-07-17) ### Added - Accept sequence of string literals ([#519]) diff --git a/hex-literal/src/comments.rs b/hex-literal/src/comments.rs index 02dd6993..135e6d53 100644 --- a/hex-literal/src/comments.rs +++ b/hex-literal/src/comments.rs @@ -28,6 +28,8 @@ impl> Iterator for ExcludingComments { State::BlockComment | State::PotentiallyLeavingBlockComment => { panic!("block comment not terminated with */") } + // No more bytes after a single '/' + State::PotentialComment { .. } => panic!("encountered invalid character: `/`"), _ => {} } }