Potential undocumented functionality of brk when called with NULL
From: Fausto Núñez Alberro <hidden>
Date: 2021-05-31 12:17:08
From: Fausto Núñez Alberro <hidden>
Date: 2021-05-31 12:17:08
Hello,
Reading the man-pages entry for brk, I found that there's a specific bit of behavior that is explicitly documented for sbrk, however not for brk:
RETURN VALUE
On success, brk() returns zero. On error, -1 is returned, and errno is set to ENOMEM.
On success, sbrk() returns the previous program break. (If the break was increased, then this value is a pointer to the start of the newly allocated memory). On error, (void *) -1 is returned, and errno is set to ENOMEM.
Here, it's stated that brk() returns zero on success and -1 on error. Some programs, though, use brk(NULL). This returns neither zero nor -1. Instead, it returns a pointer to the program break, suggesting that this functionality should be documented for brk as well.
I have made sure to read the man-pages repository as of its latest commit 65dfda3dd.
Thank you very much for your time,
Fausto