Skip to content

src: avoid redundant DataPointer reallocations#64552

Open
panva wants to merge 1 commit into
nodejs:mainfrom
panva:datapointer-resize
Open

src: avoid redundant DataPointer reallocations#64552
panva wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants