-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make malloc(0)
and posix_memalign(0)
return a non-null pointer
#3576
Comments
This is interesting. I've had this question on my mind for quite a while, how will Besides, the return value of Footnotes |
There can be metadata associated with this allocation, managed by the allocator, that would be leaked.
Implementation-defined means that the implementation gets to decide. If the user assumes that |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I wonder if we should do the same for
|
Yeah, posix_memalign shod also return non-null on size 0. (But that can be a separate PR.)
One of the key parts of the PR will be two tests to ensure we detect double free and memory leaks of malloc(0).
|
Implement non-null pointer for malloc(0) Use non-null pointer for malloc(0) as mentioned in #3576 to detect leaks and double free of ``malloc(0)`` addresses.
malloc(0)
return a non-null pointermalloc(0)
and posix_memalign(0)
return a non-null pointer
#3580 implements this for malloc; posix_memalign could get the same treatment as discussed above. |
Currently we just return a null pointer, but we're also allowed to return a unique non-zero address. That would have the benefit that we can detect leaks (not calling free) or double-free.
The text was updated successfully, but these errors were encountered: