quic: fix coverity warning
[vpp.git] / src / plugins / quic / quic_crypto.c
index b644bed..dd73003 100644 (file)
@@ -160,13 +160,12 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t * engine,
   uint8_t hpkey[PTLS_MAX_SECRET_SIZE];
   int ret;
 
-  if (hp_ctx != NULL)
-    *hp_ctx = NULL;
   *aead_ctx = NULL;
 
   /* generate new header protection key */
   if (hp_ctx != NULL)
     {
+      *hp_ctx = NULL;
       if ((ret =
           ptls_hkdf_expand_label (hash, hpkey, aead->ctr_cipher->key_size,
                                   ptls_iovec_init (secret,
@@ -209,12 +208,12 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t * engine,
 Exit:
   if (ret != 0)
     {
-      if (*aead_ctx != NULL)
+      if (aead_ctx && *aead_ctx != NULL)
        {
          ptls_aead_free (*aead_ctx);
          *aead_ctx = NULL;
        }
-      if (*hp_ctx != NULL)
+      if (hp_ctx && *hp_ctx != NULL)
        {
          ptls_cipher_free (*hp_ctx);
          *hp_ctx = NULL;