Skip to content

Commit

Permalink
Memory leak fix for key
Browse files Browse the repository at this point in the history
  • Loading branch information
aidangarske committed Dec 18, 2024
1 parent e048af9 commit e153afd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,6 @@ static int DoAsn1Key(const byte* in, word32 inSz, byte** out,

*out = newKey;
}

wolfSSH_KEY_clean(key);
}
else if (ret > 0 && isPrivate) {
if (*out == NULL) {
Expand All @@ -1795,11 +1793,10 @@ static int DoAsn1Key(const byte* in, word32 inSz, byte** out,
*outType = (const byte*)IdToName(ret);
*outTypeSz = (word32)WSTRLEN((const char*)*outType);
}
else {
WLOG(WS_LOG_DEBUG, "Unable to identify ASN.1 key");
if (*out == NULL) {
WFREE(newKey, heap, DYNTYPE_PRIVKEY);
}

wolfSSH_KEY_clean(key);
if (*out == NULL) {
WFREE(newKey, heap, DYNTYPE_PRIVKEY);
}

if (ret > 0) {
Expand Down

0 comments on commit e153afd

Please sign in to comment.