Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Oct 6, 2022

std::optional::operator*, which follows after the changed line, can cause UB.

This PR addresses #26262 (comment)

@DrahtBot DrahtBot added the Tests label Oct 6, 2022
Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

ACK 97007e2

dec should never be dereferenced if has_value() is not true.

@maflcko
Copy link
Member

maflcko commented Oct 6, 2022

BOOST_CHECK should still print the failure, making the UB more obvious, but this can't hurt.

LGTM

@maflcko maflcko merged commit 73b6171 into bitcoin:master Oct 6, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 6, 2022
97007e2 test: Prevent UB in `minisketch_tests.cpp` (Hennadii Stepanov)

Pull request description:

  [`std::optional::operator*`](https://en.cppreference.com/w/cpp/utility/optional/operator*), which follows after the changed line, can cause UB.

  This PR addresses bitcoin#26262 (comment)

ACKs for top commit:
  stickies-v:
    ACK 97007e2

Tree-SHA512: a7dde8dac0cbdfa362fa1158b4564eccff9405852612227d581690c9a34084b3467ae6d4c0269262688d75339dcea90aaa38fccbba9be92d2643c2113860f3d6
@hebasto hebasto deleted the 221006-sketch branch October 6, 2022 14:30
@bitcoin bitcoin locked and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants