Skip to content

Commit ac680c7

Browse files
committed
pkg/rpcserver: prevent a nil pointer dereference
If we get a Hanged != "" response from a non-RequestTypeProgram request, we used to end up trying to serialize an nil *prog.Prog value. Add a missing if condition.
1 parent a44b041 commit ac680c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/rpcserver/runner.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ func (runner *Runner) handleExecResult(msg *flatrpc.ExecResult) error {
436436
resErr = errors.New(msg.Error)
437437
} else if msg.Hanged {
438438
status = queue.Hanged
439-
runner.lastExec.Hanged(int(msg.Id), int(msg.Proc), req.Prog.Serialize(), osutil.MonotonicNano())
439+
if req.Type == flatrpc.RequestTypeProgram {
440+
// We only track the latest executed programs.
441+
runner.lastExec.Hanged(int(msg.Id), int(msg.Proc), req.Prog.Serialize(), osutil.MonotonicNano())
442+
}
440443
runner.hanged[msg.Id] = true
441444
}
442445
req.Done(&queue.Result{

0 commit comments

Comments
 (0)