Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87msa6sa7d.fsf@oldenburg.str.redhat.com>
Date: Tue, 17 Jun 2025 16:40:22 +0200
From: Florian Weimer <fweimer@...hat.com>
To: enh <enh@...gle.com>
Cc: Alejandro Colomar <alx@...nel.org>,  Adhemerval Zanella Netto
 <adhemerval.zanella@...aro.org>,  musl@...ts.openwall.com,
  libc-alpha@...rceware.org,  Joseph Myers <josmyers@...hat.com>,
  наб
 <nabijaczleweli@...ijaczleweli.xyz>,  Paul Eggert <eggert@...ucla.edu>,
  Robert Seacord <rcseacord@...il.com>,  Bruno Haible <bruno@...sp.org>,
  bug-gnulib@....org,  JeanHeyd Meneide <phdofthehouse@...il.com>
Subject: Re: BUG: realloc(p,0) should be consistent with malloc(0)

> ? what does Windows do?

There's quite a bit of documentation:

<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/realloc?view=msvc-170>

My favorite part is actually this:

| realloc hasn't been updated to implement C17 behavior because the new
| behavior isn't compatible with the Windows operating system.

The realloc specification update was supposed to be an editorial change
in the standard!  This is why I don't want to change anything until the
wording of the standard is finalized.

There's also this part:

| If size is zero, then the block pointed to by memblock is freed; the
| return value is NULL, and memblock is left pointing at a freed block.

And I think Windows (well, the Microsoft C runtime, which is not an
integral part of Windows, as far as I understand it) also matches the
Bionic/glibc behavior for malloc, not just for realloc:

| If size is 0, malloc allocates a zero-length item in the heap and
| returns a valid pointer to that item.

<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/malloc?view=msvc-170>

Thanks,
Florian

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.