[BUG] Mismatch in mallinfo struct between malloc.h and _mallocr.c

Stefan Baltruweit Stefan.Baltruweit@ifta.com
Thu Sep 5 14:00:36 GMT 2024


Hi Newlib Developers,

I would like to report a potential issue in Newlib libc related to a mismatch in `mallinfo` struct definitions.

**Issue Summary**:  
- In `libc/include/malloc.h` (struct `mallinfo`), the member type is defined as `size_t`.
- In `libc/stdlib/_mallocr.c` (struct `mallinfo`), the member type is defined as `int`.

On platforms where `size_t` and `int` are of different sizes, this leads to a misinterpretation of the pointer returned by `mallinfo()`.
On platforms where `size_t` and `int` are the same size, the sign mismatch will typically not be noticeable.

**Version/Environment**:
- Newlib Version: 2.2.0 - present
- This is the potential breaking change: https://inbox.sourceware.org/newlib-cvs/20130226142513.7823.qmail@sourceware.org/T/

Please let me know if further information required. 

Best regards,  
Stefan Baltruweit


More information about the Newlib mailing list