Re: Adding a realloc() usage note to the malloc(3) manual page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/1/21 5:21 PM, Michael Kerrisk (man-pages) wrote:
Obviously, '*ptr' is invalid after a
successful realloc(). But why is 'ptr' invalid?

The C standard says that once a program has freed a non-null pointer, the program cannot look at the pointer's value any more. It can't copy the value to another pointer, and it can't even test whether the value is null. A debugging implementation can trap any use of the pointer's value.

This rule is not an issue for production uses of glibc realloc. However, it could at least in theory affect debugging implementations like gcc -fsanitize=address, because the rule can help catch bugs in programs. And I vaguely recall talk that a few non-glibc platforms (IBM i, perhaps?) enforce the rule.



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux