src: fix static analysis warning and use smart ptr · nodejs/node@d8a14a2 · GitHub
Skip to content

Commit d8a14a2

Browse files
tniessenbengl
authored andcommitted
src: fix static analysis warning and use smart ptr
Coverity issues a warning about `value_before_reset == ca`, where value_before_reset is a pointer that may not be valid. While comparing the pointer itself should still work, we should really be using smart pointers here so that this particular check can be simplified without running into a memory leak. Refactor SSL_CTX_get_issuer to return a smart pointer and update the call sites accordingly. Note that we might have to change that in the future once we improve error handling throughout crypto/tls. Refs: #37990 PR-URL: #43117 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 6f48dfb commit d8a14a2

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

src/crypto/crypto_common.cc

Lines changed: 18 additions & 15 deletions

src/crypto/crypto_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct StackOfXASN1Deleter {
2525
};
2626
using StackOfASN1 = std::unique_ptr<STACK_OF(ASN1_OBJECT), StackOfXASN1Deleter>;
2727

28-
bool SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer);
28+
X509Pointer SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert);
2929

3030
void LogSecret(
3131
const SSLPointer& ssl,

src/crypto/crypto_context.cc

Lines changed: 6 additions & 6 deletions

0 commit comments

Comments
 (0)