]> granicus.if.org Git - esp-idf/commitdiff
mbedtls: Fix memory leak in initial ECDH exchange if OOM/failure occurs
authorAngus Gratton <angus@espressif.com>
Wed, 12 Jul 2017 08:34:26 +0000 (16:34 +0800)
committerAngus Gratton <gus@projectgus.com>
Wed, 12 Jul 2017 08:34:26 +0000 (16:34 +0800)
In ecp_mul_comb(), if (!p_eq_g && grp->T == NULL) and ecp_precompute_comb() fails (which can happen due to OOM), then the new array of points T was leaked.

components/mbedtls/library/ecp.c

index f51f2251edf8ce3a30802aff93f05c7629ad9e9d..fa5d0ddc1595265069d924b35a3743cd168d5de5 100644 (file)
@@ -1406,7 +1406,7 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
 
 cleanup:
 
-    if( T != NULL && ! p_eq_g )
+    if( T != NULL && T != grp->T )
     {
         for( i = 0; i < pre_len; i++ )
             mbedtls_ecp_point_free( &T[i] );