Skip to content

wincng: de-duplicate two conditionals in ssh2_ecdsa_create_key() - #2300

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:wcngtid
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:wcngtid

Conversation

@vszakats

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to simplify error-path cleanup in the Windows CNG ECDSA key generation routine by de-duplicating conditional checks in ssh2_ecdsa_create_key().

Changes:

  • Refactors the cleanup: block to wrap multiple frees/destroys under a single if(result != LIBSSH2_ERROR_NONE) condition.
  • Introduces additional cleanup for an output pointer (but currently references a non-existent symbol).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wincng.c
Comment on lines +2127 to +2134
if(result != LIBSSH2_ERROR_NONE) {
if(key_handle)
(void)BCryptDestroyKey(key_handle);
if(*out_private_key)
free(*out_private_key);
if(*ec_ctx)
free(*ec_ctx);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

→ PR #2306

@vszakats vszakats changed the title wincng: de-duplicate two conditional in ssh2_ecdsa_create_key() wincng: de-duplicate two conditionals in ssh2_ecdsa_create_key() Jul 14, 2026
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