fix a potential double free
authorjsg <jsg@openbsd.org>
Thu, 17 Apr 2014 17:11:10 +0000 (17:11 +0000)
committerjsg <jsg@openbsd.org>
Thu, 17 Apr 2014 17:11:10 +0000 (17:11 +0000)
ok miod@

lib/libssl/d1_srvr.c
lib/libssl/src/ssl/d1_srvr.c

index 9b87dcd..ce7b243 100644 (file)
@@ -1290,6 +1290,7 @@ dtls1_send_server_key_exchange(SSL *s)
                        (unsigned char *)encodedPoint,
                        encodedlen);
                        free(encodedPoint);
+                       encodedPoint = NULL;
                        p += encodedlen;
                }
 #endif
@@ -1397,8 +1398,7 @@ f_err:
        ssl3_send_alert(s, SSL3_AL_FATAL, al);
 err:
 #ifndef OPENSSL_NO_ECDH
-       if (encodedPoint != NULL)
-               free(encodedPoint);
+       free(encodedPoint);
        BN_CTX_free(bn_ctx);
 #endif
        EVP_MD_CTX_cleanup(&md_ctx);
index 9b87dcd..ce7b243 100644 (file)
@@ -1290,6 +1290,7 @@ dtls1_send_server_key_exchange(SSL *s)
                        (unsigned char *)encodedPoint,
                        encodedlen);
                        free(encodedPoint);
+                       encodedPoint = NULL;
                        p += encodedlen;
                }
 #endif
@@ -1397,8 +1398,7 @@ f_err:
        ssl3_send_alert(s, SSL3_AL_FATAL, al);
 err:
 #ifndef OPENSSL_NO_ECDH
-       if (encodedPoint != NULL)
-               free(encodedPoint);
+       free(encodedPoint);
        BN_CTX_free(bn_ctx);
 #endif
        EVP_MD_CTX_cleanup(&md_ctx);