Skip to content

pj_pool_alloc_from_block: Eliminate unsafe cast#4927

Open
kunkku wants to merge 1 commit intopjsip:masterfrom
kunkku:fix-alloc-size-check
Open

pj_pool_alloc_from_block: Eliminate unsafe cast#4927
kunkku wants to merge 1 commit intopjsip:masterfrom
kunkku:fix-alloc-size-check

Conversation

@kunkku
Copy link
Copy Markdown
Contributor

@kunkku kunkku commented Apr 17, 2026

If the most significant bit of the size argument was set, casting to pj_ssize_t yielded a negative value, causing false positives in the size check. This resulted in returning a pointer to a buffer that has less capacity than requested.

This fixes regressions caused by #4382, #4389 and #4391. The original check prior to these PRs was correct, though a bit hard to read for both humans and compilers.

If the most significant bit of the size argument was set, casting to
pj_ssize_t yielded a negative value, causing false positives in the size
check. This resulted in returning a pointer to a buffer that has less
capacity than requested.

This fixes regressions in the following commits:
* 9f3a3d4
* 43a652a
* 214b609

The original check prior to these commits was correct, though a bit hard
to read for both humans and compilers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant