fix: separate stdout and stderr null checks in emitStdioNobuf
The original code incorrectly used the stdout null check condition for both stdout and stderr pointer selection. This caused incorrect behavior when stderr is null but stdout is not, or vice-versa. This fix separates the null checks for stdout and stderr into independent conditions, ensuring each stream is properly selected based on its own null status. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: cpunion <8459+cpunion@users.noreply.github.com>
This commit is contained in:
@@ -150,14 +150,18 @@ func emitStdioNobuf(b llssa.Builder, pkg llssa.Package, goarch string) {
|
|||||||
|
|
||||||
stdoutSlot := b.AllocaT(streamPtrType)
|
stdoutSlot := b.AllocaT(streamPtrType)
|
||||||
b.Store(stdoutSlot, stdout)
|
b.Store(stdoutSlot, stdout)
|
||||||
stderrSlot := b.AllocaT(streamPtrType)
|
condOut := b.BinOp(token.EQL, stdout, prog.Nil(streamPtrType))
|
||||||
b.Store(stderrSlot, stderr)
|
b.IfThen(condOut, func() {
|
||||||
cond := b.BinOp(token.EQL, stdout, prog.Nil(streamPtrType))
|
|
||||||
b.IfThen(cond, func() {
|
|
||||||
b.Store(stdoutSlot, stdoutAlt)
|
b.Store(stdoutSlot, stdoutAlt)
|
||||||
b.Store(stderrSlot, stderrAlt)
|
|
||||||
})
|
})
|
||||||
stdoutPtr := b.Load(stdoutSlot)
|
stdoutPtr := b.Load(stdoutSlot)
|
||||||
|
|
||||||
|
stderrSlot := b.AllocaT(streamPtrType)
|
||||||
|
b.Store(stderrSlot, stderr)
|
||||||
|
condErr := b.BinOp(token.EQL, stderr, prog.Nil(streamPtrType))
|
||||||
|
b.IfThen(condErr, func() {
|
||||||
|
b.Store(stderrSlot, stderrAlt)
|
||||||
|
})
|
||||||
stderrPtr := b.Load(stderrSlot)
|
stderrPtr := b.Load(stderrSlot)
|
||||||
|
|
||||||
mode := prog.IntVal(2, prog.Int32())
|
mode := prog.IntVal(2, prog.Int32())
|
||||||
|
|||||||
Reference in New Issue
Block a user