Skip to content

tree: use correct argument order for allocation functions - #25079

Merged
Girgias merged 3 commits into
php:masterfrom
Girgias:2026-10-safe_emalloc-nmeb-size
Nov 2, 2026
Merged

Girgias merged 3 commits into
php:masterfrom
Girgias:2026-10-safe_emalloc-nmeb-size

Conversation

@Girgias

@Girgias Girgias commented Oct 31, 2026

Copy link
Copy Markdown
Member

Note these changes were done via a manual audit.

The motivation for using sizeof(char) rather than a literal 1 is to make the intention clearer, as a plain 1 can also mean "allocate 1 element of this alignment" and determining this meaning is not necessarily immediately obvious.

I might have missed some cases, but hopefully it is all of them.

It is (nmemb, size, offset) not (size, nmemb, offset).

Use sizeof(char) instead of 1
For quoting allocations use (lenght*2, sizeof(char), offset) rather than various different combinations.
It is (ptr, nmemb, size, offset) not (ptr, size, nmemb, offset).
It is (nmemb, size) not (size, nmemb).

Use sizeof(char) instead of literal 1 in some cases

@NattyNarwhal NattyNarwhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for odbc

@Girgias
Girgias merged commit c23eb1a into php:master Nov 2, 2026
18 checks passed
@Girgias
Girgias deleted the 2026-10-safe_emalloc-nmeb-size branch November 2, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants