[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/main] cc: Fix memleak when building extension response



commit d09e58d9bf0a2c94cec886756351cb718cb31959
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Wed Feb 23 13:22:59 2022 -0500

    cc: Fix memleak when building extension response
    
    Fixes #40575
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/core/or/congestion_control_common.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c
index fb56014315..93d3a9f2c5 100644
--- a/src/core/or/congestion_control_common.c
+++ b/src/core/or/congestion_control_common.c
@@ -1303,6 +1303,7 @@ congestion_control_build_ext_response(const circuit_params_t *our_params,
 
     ret = trn_extension_field_cc_encoded_len(cc_field);
     if (BUG(ret <= 0)) {
+      trn_extension_field_free(field);
       goto err;
     }
     size_t field_len = ret;
@@ -1313,6 +1314,7 @@ congestion_control_build_ext_response(const circuit_params_t *our_params,
     ret = trn_extension_field_cc_encode(field_array,
               trn_extension_field_getlen_field(field), cc_field);
     if (BUG(ret <= 0)) {
+      trn_extension_field_free(field);
       goto err;
     }
 
@@ -1340,11 +1342,7 @@ congestion_control_build_ext_response(const circuit_params_t *our_params,
   ret = 0;
 
  err:
-  if (ext) {
-    trn_extension_free(ext);
-  } else {
-    trn_extension_field_free(field);
-  }
+  trn_extension_free(ext);
   trn_extension_field_cc_free(cc_field);
   return (int)ret;
 }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits