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

Jeff Johnston jjohnstn@redhat.com
Mon Sep 16 23:23:06 GMT 2024


Thanks Stefan.  I have pushed a patch so the two structures match.

-- Jeff J.

On Thu, Sep 5, 2024 at 10:01 AM Stefan Baltruweit <
Stefan.Baltruweit@ifta.com> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/newlib/attachments/20240916/69c5b981/attachment.htm>


More information about the Newlib mailing list