Skip to content

Commit 4a5ad9d

Browse files
authored
fix: prevent partial state mutation in PutPollResult.LoadProto (#4796)
1 parent f3455a7 commit 4a5ad9d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

action/putpollresult.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ func (r *PutPollResult) LoadProto(putPollResultPb *iotextypes.PutPollResult) err
3838
if r == nil {
3939
return ErrNilAction
4040
}
41-
*r = PutPollResult{}
42-
43-
r.height = putPollResultPb.Height
41+
temp := PutPollResult{}
42+
if err := temp.candidates.LoadProto(putPollResultPb.Candidates); err != nil {
43+
return err
44+
}
45+
temp.height = putPollResultPb.Height
4446

45-
return r.candidates.LoadProto(putPollResultPb.Candidates)
47+
*r = temp
48+
return nil
4649
}
4750

4851
func (act *PutPollResult) FillAction(core *iotextypes.ActionCore) {

0 commit comments

Comments
 (0)