From efb9e41cd6caca8ed586f066ad628791e15b51b2 Mon Sep 17 00:00:00 2001 From: daschinmoy21 Date: Sat, 28 Feb 2026 20:06:55 +0530 Subject: [PATCH] fix(cli): prevent ariadne from panicking on empty stdin When statix receives an empty string via stdin, an empty Report is generated. Passing an empty string to ariadne's Source::from causes an index out of bounds panic. Supplying a string with a single space as a fallback prevents this panic while keeping the error location at byte offset 0. --- bin/src/traits.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/src/traits.rs b/bin/src/traits.rs index 284adf4b..59474de3 100644 --- a/bin/src/traits.rs +++ b/bin/src/traits.rs @@ -86,7 +86,10 @@ fn write_stderr( }, ) .finish() - .write((src_id, Source::from(src)), &mut *writer)?; + .write( + (src_id, Source::from(if src.is_empty() { " " } else { src })), + &mut *writer, + )?; } Ok(()) }