anchao opened a new pull request, #21067:
URL: https://github.com/apache/nuttx/pull/21067
## Summary
Handle zero alignment values in `mm_memalign()` by treating them as a
request
for the natural malloc alignment.
Previously, `mm_memalign()` accepted `alignment == 0` because the
power-of-two
check also passed for zero. That could later hit the natural-alignment fast
path
and trigger the debug alignment assertion with a modulo-by-zero operation.
This change normalizes zero alignment to `MM_ALIGN` before the validation
and
allocation logic. Internal callers that pass zero when no extra alignment is
required keep the same allocation semantics as a regular naturally aligned
malloc allocation.
## Impact
This fixes a zero-alignment edge case in heap allocation.
Expected impact:
- prevents modulo-by-zero in the debug alignment assertion
- preserves natural malloc alignment behavior for callers that do not
require
extra alignment
- keeps existing rejection behavior for invalid non-power-of-two alignments
- no API, ABI, build-system, documentation, or security impact is expected
## Testing
sim/nsh
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]