Skip to content

fix(cpp): remove UB when reading unset builder vertex id#892

Open
Sober7135 wants to merge 2 commits intoapache:mainfrom
Sober7135:846-remove-ub
Open

fix(cpp): remove UB when reading unset builder vertex id#892
Sober7135 wants to merge 2 commits intoapache:mainfrom
Sober7135:846-remove-ub

Conversation

@Sober7135
Copy link
Contributor

Reason for this PR

#846

What changes are included in this PR?

  • Represent builder::Vertex id as std::optional<IdType> instead of an uninitialized scalar
  • Make GetId() fail explicitly when the id is unset, instead of reading uninitialized memory
  • Remove the stored empty_ flag from builder::Vertex
  • Derive Empty() from properties_.empty() so vertex emptiness is no longer tracked by redundant mutable state
  • Add/adjust tests to cover:
    • default-constructed vertex with unset id
    • SetId() / constructor-initialized id behavior
    • Empty() behavior after removing the stored empty_ field

Are these changes tested?

Yes

Are there any user-facing changes?

Yes

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.87%. Comparing base (d535a43) to head (8255be0).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #892      +/-   ##
============================================
+ Coverage     79.81%   79.87%   +0.05%     
  Complexity      615      615              
============================================
  Files            93       93              
  Lines         10296    10296              
  Branches       1055     1055              
============================================
+ Hits           8218     8224       +6     
+ Misses         1838     1832       -6     
  Partials        240      240              
Flag Coverage Δ
cpp 70.91% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sober7135 Sober7135 marked this pull request as ready for review March 1, 2026 10:16
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.

2 participants