From fc7f291a68b6741e457299bd65b7c8312a0b8648 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Fri, 20 Jun 2014 15:12:08 -0700 Subject: [PATCH] echo: check argument length when parsing options --- echo/echo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo/echo.rs b/echo/echo.rs index aa815ec35..1ba00d0a1 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -96,7 +96,7 @@ fn parse_options(args: Vec, options: &mut EchoOptions) -> Option options.escape = true, "-E" => options.escape = false, _ => { - if arg.as_slice().char_at(0) == '-' && arg.len() > 1 { + if arg.len() > 1 && arg.as_slice().char_at(0) == '-' { let mut newopts = options.clone(); let argptr: *String = &arg; // escape from the borrow checker for ch in unsafe { (*argptr).as_slice() }.chars().skip(1) {