Skip to content

Commit d7a9da2

Browse files
authored
Merge pull request #1117 from samhocevar-forks/fix/argv-handling-crash
Do not panic in ‘os’ module if argv.Length() is 0
2 parents 3c2c4dc + c870983 commit d7a9da2

File tree

1 file changed

+1
-1
lines changed
  • compiler/natives/src/os

1 file changed

+1
-1
lines changed

compiler/natives/src/os/os.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func runtime_args() []string { // not called on Windows
1818

1919
func init() {
2020
if process := js.Global.Get("process"); process != js.Undefined {
21-
if argv := process.Get("argv"); argv != js.Undefined {
21+
if argv := process.Get("argv"); argv != js.Undefined && argv.Length() >= 1 {
2222
Args = make([]string, argv.Length()-1)
2323
for i := 0; i < argv.Length()-1; i++ {
2424
Args[i] = argv.Index(i + 1).String()

0 commit comments

Comments
 (0)