[SERVER-60596] Replace boost::optional::get() with boost::optional::value in DensifyValue to avoid undefined behavior Created: 11/Oct/21  Updated: 29/Oct/23  Resolved: 12/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.3.0, 5.1.0-rc1

Type: Improvement Priority: Major - P3
Reporter: Davis Haupt (Inactive) Assignee: Davis Haupt (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.1
Participants:
Linked BF Score: 115

 Description   

boost::optional::get() has undefined behavior without checking if the optional exists with has_value() first. We are already switching on the underlying type of the variant _value, so if we want to throw an assertion if the invariant that the densify value and the densify unit are different, we should switch to boost::optional::value() in those cases.



 Comments   
Comment by Githook User [ 15/Oct/21 ]

Author:

{'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}

Message: SERVER-60596 replace optional::get() with optional::value()
Branch: v5.1
https://github.com/mongodb/mongo/commit/5f82908d217a160aa309e90bacc5d336de823322

Comment by Githook User [ 12/Oct/21 ]

Author:

{'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}

Message: SERVER-60596 replace optional::get() with optional::value()
Branch: master
https://github.com/mongodb/mongo/commit/c15b06d90daf2a1201985dab03d3de8cef02371a

Generated at Thu Feb 08 05:50:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.