Skip to content

nil pointer deref in CometBlockResultByNumber error path #1066

@Aboudjem

Description

@Aboudjem

Was tracing an intermittent RPC crash on a pruned archive node. The function sets height = nil when the incoming pointer holds 0, to let CometBFT resolve the latest block. If the subsequent BlockResults call then fails (timeout, pruned state, network error), the error format string at line 71 tries to dereference height, which is now nil. The panic only surfaces under error conditions, so it never shows up in happy-path tests.

Fix is one line: capture the int64 value before nullifying the pointer, then use that value in the error message instead of dereferencing height.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions