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 unsafeTraverse error handling #5661

Merged
merged 2 commits into from
Apr 23, 2024

Conversation

zhangchiqing
Copy link
Member

The a nil pointer error in the error handling of the unsafeTraverse function.

@@ -107,9 +107,11 @@ func unsafeTraverse(headers storage.Headers, block *flow.Header, visitor onVisit
return block, nil
}

block, err = headers.ByBlockID(block.ParentID)
parent, err := headers.ByBlockID(block.ParentID)
if err != nil {
return nil, fmt.Errorf("failed to revtrieve block header %x: %w", block.ParentID, err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, block could be nil, and causing nil pointer error

if err != nil {
return nil, fmt.Errorf("failed to revtrieve block header %x: %w", block.ParentID, err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, block could be nil, and causing nil pointer error

state/fork/traversal.go Outdated Show resolved Hide resolved
@zhangchiqing zhangchiqing enabled auto-merge April 15, 2024 15:57
zhangchiqing and others added 2 commits April 22, 2024 11:45
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
@zhangchiqing zhangchiqing force-pushed the leo/fix-traversal-error-handling branch from 0d7d312 to 4860e67 Compare April 22, 2024 18:45
@zhangchiqing zhangchiqing added this pull request to the merge queue Apr 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 23, 2024
@zhangchiqing zhangchiqing added this pull request to the merge queue Apr 23, 2024
Merged via the queue into master with commit eff9395 Apr 23, 2024
55 checks passed
@zhangchiqing zhangchiqing deleted the leo/fix-traversal-error-handling branch April 23, 2024 00:44
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.

3 participants