[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


            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>

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

% ./a.out        

Twitter thread for reference:

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

More information about the freebsd-standards mailing list