1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os.executable: fix panic when os.executable_fallback fails (early in startup)

This commit is contained in:
Delyan Angelov 2020-04-23 21:52:13 +03:00
parent 1247718cbd
commit ebc41375f1

View File

@ -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 ) {