Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Sep 2019 19:44:34 +0000
From:      bugzilla-noreply@freebsd.org
To:        standards@FreeBSD.org
Subject:   [Bug 240456] realloc(x, 0) should not return NULL
Message-ID:  <bug-240456-99@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D240456

            Bug ID: 240456
           Summary: realloc(x, 0) should not return NULL
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: standards
          Assignee: standards@FreeBSD.org
          Reporter: emaste@freebsd.org

In the same way that malloc(0) returns non-NULL, realloc(x, 0) should retur=
n a
pointer to an allocation of size 0, not NULL.

test case:

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
        printf("%p\n", realloc(malloc(1), 0));
}

% ./a.out=20=20=20=20=20=20=20=20
0x0

Twitter thread for reference:
https://twitter.com/RichFelker/status/1171108501751554048

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-240456-99>