Skip to content

src: avoid redundant DataPointer reallocations#64552

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:datapointer-resize
Jul 21, 2026
Merged

src: avoid redundant DataPointer reallocations#64552
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
panva:datapointer-resize

Conversation

@panva

@panva panva commented Jul 17, 2026

Copy link
Copy Markdown
Member

DataPointer::resize() checked for an unchanged size only after release() had reset the stored length to zero. As a result, every non-empty resize called OPENSSL_realloc(), even when the allocation was already the right size.

Check for the no-op before releasing the buffer. This avoids an allocator call and, with BoringSSL, a new allocation, copy, cleanse, and free.

Keep the explicit zero-length path to preserve successful empty crypto outputs.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. labels Jul 17, 2026
@panva
panva requested a review from jasnell July 17, 2026 08:41
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 19, 2026
@panva panva added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 21, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 21, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 0b7aa61 into nodejs:main Jul 21, 2026
78 of 79 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0b7aa61

@panva
panva deleted the datapointer-resize branch July 21, 2026 15:50
@panva panva added the backport-open-v26.x Indicate that the PR has an open backport label Jul 21, 2026
aduh95 pushed a commit to panva/node that referenced this pull request Jul 21, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: nodejs#64552
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backport-open-v26.x Indicate that the PR has an open backport dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants