[Bug 240456] realloc(x, 0) should not return NULL

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Sep 9 19:44:35 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240456

            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 at FreeBSD.org
          Reporter: emaste at freebsd.org

In the same way that malloc(0) returns non-NULL, realloc(x, 0) should return 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        
0x0

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

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


More information about the freebsd-standards mailing list