]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
encoder: fix coverity 1473235: null dereference
authorPauli <ppzgs1@gmail.com>
Fri, 19 Mar 2021 03:05:16 +0000 (13:05 +1000)
committerPauli <pauli@openssl.org>
Thu, 25 Mar 2021 22:44:04 +0000 (08:44 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14618)

crypto/encode_decode/encoder_pkey.c

index fc5a3914204a9b4a7632782e5bb6ab6cb07cc2ba..713aa44131a3d3f8234f6b453839976c6e9c2f04 100644 (file)
@@ -261,7 +261,7 @@ static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx,
         }
     }
 
-    if (OSSL_ENCODER_CTX_get_num_encoders(ctx) != 0) {
+    if (data != NULL && OSSL_ENCODER_CTX_get_num_encoders(ctx) != 0) {
         if (!OSSL_ENCODER_CTX_set_construct(ctx, encoder_construct_pkey)
             || !OSSL_ENCODER_CTX_set_construct_data(ctx, data)
             || !OSSL_ENCODER_CTX_set_cleanup(ctx, encoder_destruct_pkey))