Skip to content

Fix overflow handling in roundupsize#43

Open
AADARSHPUROHIT466 wants to merge 1 commit intognu-octave:defaultfrom
AADARSHPUROHIT466:fix-roundupsize-overflow
Open

Fix overflow handling in roundupsize#43
AADARSHPUROHIT466 wants to merge 1 commit intognu-octave:defaultfrom
AADARSHPUROHIT466:fix-roundupsize-overflow

Conversation

@AADARSHPUROHIT466
Copy link
Contributor

This patch improves the safety of the roundupsize function in liboctave/util/oct-sort.cc.

Problem

The original implementation used:

std::size_t new_size = ((n >> nbits) + 1) << nbits;

- Split size calculation to prevent integer overflow
- Add explicit overflow check before multiplication
- Fix getmemi to verify both m_a and m_ia pointers
- Follow GNU Octave coding style conventions
@sonarqubecloud
Copy link

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

Comments