From ebc41375f19e12bb51988556d9b1d77eb366d3a7 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 23 Apr 2020 21:52:13 +0300 Subject: [PATCH] os.executable: fix panic when os.executable_fallback fails (early in startup) --- vlib/os/os.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/os/os.v b/vlib/os/os.v index ce678f68b8..00eeb9226d 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -891,6 +891,10 @@ pub fn executable() string { // it relies on path manipulation of os.args[0] and os.wd_at_startup, so it may not work properly in // all cases, but it should be better, than just using os.args[0] directly. fn executable_fallback() string { + if os.args.len == 0 { + // we are early in the bootstrap, os.args has not been initialized yet :-| + return '' + } mut exepath := os.args[0] if !os.is_abs_path(exepath) { if exepath.contains( os.path_separator ) {