[musl] Re: BUG: realloc(p, 0) should be consistent with malloc(0)

Laurent Bercot ska-dietlibc@skarnet.org
Tue Jun 17 17:38:03 GMT 2025


>And folks who do
>know aren't complaining that it's broken, because the behavior is
>currently conforming just bad. Rather they're tiptoeing around the
>issue by special-casing zero and making sure they never pass zero to
>realloc, or wrapping it to do that, etc.

  Anecdotal data point: it's exactly what I do, wrapping all the malloc
and realloc calls so that they're never passed 0. It's by far the
simplest solution for now, at the occasional cost of 1 byte of memory.
It would be nice to have this fixed, *and standardized*; the workarounds
aren't going away until it is, and until every libc deployed under the
sun implements the new, better standard. I'm not holding my breath.

--
  Laurent



More information about the Libc-alpha mailing list