From 9f039c7cc73e2724348d5fac9c188b89da9ac9e4 Mon Sep 17 00:00:00 2001 From: MineRobber9000 Date: Sat, 30 Nov 2024 05:20:58 -0500 Subject: [PATCH] Fix panic when incbin'ing an empty file If you incbin an empty file, the code I wrote for including ranges assumes you gave it an invalid start and tries to report an error on an argument that wasn't provided. This fixes that by short-circuiting to returning an empty value if there are no bytes in the file. --- src/asm/resolver/eval_fn.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/asm/resolver/eval_fn.rs b/src/asm/resolver/eval_fn.rs index 6fcceec1..9d189c3f 100644 --- a/src/asm/resolver/eval_fn.rs +++ b/src/asm/resolver/eval_fn.rs @@ -176,6 +176,11 @@ fn eval_builtin_incbin( } }; + if bytes.len() == 0 + { + return Ok(expr::Value::make_integer(util::BigInt::from_bytes_be(&[]))); + } + if start >= bytes.len() { query.report.error_span(