Skip to content

Commit

Permalink
Fix panic when incbin'ing an empty file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MineRobber9000 authored and hlorenzi committed Dec 1, 2024
1 parent 602919d commit 9f039c7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/asm/resolver/eval_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9f039c7

Please sign in to comment.