Skip to content
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

buffer: don't CHECK on zero-sized realloc #3499

Merged
merged 1 commit into from
Oct 23, 2015

Conversation

bnoordhuis
Copy link
Member

malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
that the standard allows them to either return a unique pointer or a
nullptr for zero-sized allocation requests. Normalize by always using
a nullptr.

Fixes: #3496

R=@trevnorris

CI: https://ci.nodejs.org/job/node-test-pull-request/582/

@bnoordhuis bnoordhuis added the buffer Issues and PRs related to the buffer subsystem. label Oct 23, 2015
@trevnorris
Copy link
Contributor

LGTM

@thefourtheye
Copy link
Contributor

LGTM

malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
that the standard allows them to either return a unique pointer or a
nullptr for zero-sized allocation requests.  Normalize by always using
a nullptr.

Fixes: nodejs#3496
PR-URL: nodejs#3499
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
@bnoordhuis bnoordhuis closed this Oct 23, 2015
@bnoordhuis bnoordhuis deleted the fix3496 branch October 23, 2015 20:59
@bnoordhuis bnoordhuis merged commit 594500f into nodejs:master Oct 23, 2015
bnoordhuis added a commit that referenced this pull request Oct 26, 2015
malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
that the standard allows them to either return a unique pointer or a
nullptr for zero-sized allocation requests.  Normalize by always using
a nullptr.

Fixes: #3496
PR-URL: #3499
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
@jasnell
Copy link
Member

jasnell commented Oct 26, 2015

Landed in v4.x-staging in 287e830

bnoordhuis added a commit that referenced this pull request Oct 26, 2015
malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
that the standard allows them to either return a unique pointer or a
nullptr for zero-sized allocation requests.  Normalize by always using
a nullptr.

Fixes: #3496
PR-URL: #3499
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
bnoordhuis added a commit that referenced this pull request Oct 29, 2015
malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
that the standard allows them to either return a unique pointer or a
nullptr for zero-sized allocation requests.  Normalize by always using
a nullptr.

Fixes: #3496
PR-URL: #3499
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants