anchao opened a new pull request, #21438:
URL: https://github.com/apache/nuttx/pull/21438
## Summary
When `realloc()` moves a block forward by consuming a preceding free
chunk (the `takeprev` path in `mm_realloc.c`), the destination starts
at a lower address than the source and the two user regions overlap.
The previous code used `memcpy()`, whose behavior is undefined for
overlapping regions. Depending on libc optimizations, architecture,
or compiler settings this could corrupt user data.
Switch to `memmove()`, which is guaranteed to handle overlapping
regions correctly.
## Impact
- **New behavior**: Overlapping downward copy in `realloc()` uses
`memmove()` instead of `memcpy()`.
- **User impact**: Fixes a potential data-corruption bug in the default
heap allocator path.
- **Build**: None (no new dependencies).
- **Documentation**: None.
- **Security**: None (bug fix; reduces undefined behavior).
## 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]