diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2025-12-15 11:54:36 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2025-12-15 12:29:01 +0100 |
| commit | d64ed8c531b03a75d4e20d48f5d5f662898e60f7 (patch) | |
| tree | 1c72b24a7d5acb4e99a9073f8862770e69547b6b /lib/xixanta/src/parser.rs | |
| parent | 4961b715328d43e721697457c35968618168760f (diff) | |
| download | tools.nes-d64ed8c531b03a75d4e20d48f5d5f662898e60f7.tar.gz tools.nes-d64ed8c531b03a75d4e20d48f5d5f662898e60f7.zip | |
Do not allow empty strings on .include
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib/xixanta/src/parser.rs')
| -rw-r--r-- | lib/xixanta/src/parser.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs index 7a892b0..e227ade 100644 --- a/lib/xixanta/src/parser.rs +++ b/lib/xixanta/src/parser.rs @@ -923,6 +923,15 @@ impl Parser { // working directory. This way we construct the absolute path for the // given file. let file_path = self.fetch_path_from(node.args.as_ref().unwrap().first().unwrap())?; + if file_path.is_empty() { + return Err(Error { + line: node.value.line, + global: false, + source: self.sources.get(self.current_source).unwrap().clone(), + message: ".include statement with an empty string".to_string(), + } + .into()); + } let Some(current_source) = self.sources.get(self.current_source) else { panic!("mismatch between the number of sources and the current one"); }; @@ -2074,6 +2083,21 @@ mod tests { ); } + #[test] + fn error_on_empty_include_string() { + let mut parser = Parser::default(); + let line = ".include \" \""; + + let err = parser + .parse(line.as_bytes(), &SourceInfo::default()) + .unwrap_err(); + + assert_eq!( + err.first().unwrap().message, + ".include statement with an empty string" + ); + } + // Regular instructions. #[test] |
