Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing nil check #971

Merged
merged 2 commits into from
Dec 31, 2022
Merged

fix: add missing nil check #971

merged 2 commits into from
Dec 31, 2022

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Dec 30, 2022

Fixes #961.

This problem occurs when a user uses version: '2' in their Taskfile in combination with a Taskfile_{{OS}}.yml file. In the case of #961, I'm guessing there was only a Taskfile_windows.yml file which is why the issue doesn't repro on Linux.

This happens because the Merge function is called with includedTaskfile set to nil:

if v < 3.0 {
path = filepathext.SmartJoin(readerNode.Dir, fmt.Sprintf("Taskfile_%s.yml", runtime.GOOS))
if _, err = os.Stat(path); err == nil {
osTaskfile, err := readTaskfile(path)
if err != nil {
return nil, "", err
}
if err = taskfile.Merge(t, osTaskfile, nil); err != nil {
return nil, "", err
}
}
}

This value is then not being nil checked in the Merge function here:

task.Internal = task.Internal || includedTaskfile.Internal

The fix simply adds a nil check to this line.

@andreynering andreynering added the type: bug Something not working as intended. label Dec 31, 2022
@andreynering
Copy link
Member

Thanks!

@andreynering andreynering merged commit c4766e2 into master Dec 31, 2022
@andreynering andreynering deleted the fix-nil-pointer branch December 31, 2022 16:54
@pd93 pd93 mentioned this pull request Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task throwing runtime error, 'invalid memory address'
2 participants