Skip to content

ByteParser.bytesToUint64: require check too early #12

@gsalzer

Description

@gsalzer

The require check in ByteParser.bytesToUint64 happens too early: The return value of the function that is only computed in the next row, is already checked when entering the function. As new variables seem to be initialized to zero, the check always succeeds, but misses its purpose.

    function bytesToUint64(bytes memory data) public pure returns (uint64 value) {
        require(value <= MAX_UINT64, "Number too large! Use `bytesToBigNumber` instead!");
        value = uint64(bytesToBigNumber(data));
    }

Fix: Move the require statement below the assignment.

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