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

Do not panic when StdIn is closed #1867

Merged
merged 1 commit into from Nov 18, 2023

Conversation

aleskandro
Copy link
Contributor

@aleskandro aleskandro commented Nov 17, 2023

Hi, this PR proposes a fix for scenarios when yq executes in an env with stdin closed. It also adds an acceptance test case for this scenario.

When the shell executing yq has no open stdin, os.Stdin.Stat() returns nil, and yq fails to continue. This commit fixes a missing verification on the result of os.Stdin.Stat() in the utils.processStdInArgs function and adds an acceptance test to cover this scenario in the future. This bug has affected yq since version 4.26.1.

It is reproducible till the latest version in master by:

cat >test.yml <<EOL
a: 1
EOL
./yq e test.yml <&-

Fixes #1868

When the shell executing yq has no open stdin, os.Stdin.Stat() return nil and yq fails to continue. This commit fixes a missing verification on the result of os.Stdin.Stat() in the utils.processStdInArgs function and adds an acceptance test to cover this scenario in the future. This bug affects yq since version 4.26.1.
@mikefarah mikefarah merged commit e5cc57b into mikefarah:master Nov 18, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

closed stdin leads to runtime error: invalid memory address or nil pointer dereference
2 participants