Skip to content

refactor: remove dead EVP_PKEY_CTX_free(pctx) calls#127

Merged
timlegge merged 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/dead-pctx-free-cleanup
Mar 21, 2026
Merged

refactor: remove dead EVP_PKEY_CTX_free(pctx) calls#127
timlegge merged 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/dead-pctx-free-cleanup

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Mar 19, 2026

What

Remove two unreachable EVP_PKEY_CTX_free(pctx) calls in _new_key_from_parameters().

Why

Both calls operate on a guaranteed-NULL pointer. The pctx resource is already freed and NULLed:

  • Success paths: at line 738 (full private key branch) and line 761 (d-only/public key branch)
  • Error path: at line 784 in the err: cleanup block

The dead calls at lines 792 (inside if (error)) and 799 (at end: label) obscure the actual resource ownership flow and suggest cleanup is still needed when it isn't.

How

Deleted 6 lines — the two EVP_PKEY_CTX_free(pctx) calls and their #if guards. No behavioral change.

Testing

460 tests pass before and after (macOS, OpenSSL 3.x).


🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 6 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

…ters()

Both calls were unreachable: pctx is always freed and NULLed before
these points — at line 738/761 on success paths, and at line 784 in
the err: cleanup block. Removing them clarifies resource ownership
and eliminates misleading cleanup code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@timlegge timlegge marked this pull request as ready for review March 21, 2026 00:59
@timlegge timlegge merged commit 2e6d4da into cpan-authors:main Mar 21, 2026
55 checks passed
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.

2 participants