[PATCH 1/3] tests/bench-slope: fix memory-leak and use-after-free bugs

Jussi Kivilinna jussi.kivilinna at iki.fi
Tue Mar 10 17:57:27 CET 2015


* tests/bench-slope.c (do_slope_benchmark): Free 'measurements' at end.
(bench_mac_init): Move 'key' free at end of function.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 tests/bench-slope.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/bench-slope.c b/tests/bench-slope.c
index c309b7e..394d7fc 100644
--- a/tests/bench-slope.c
+++ b/tests/bench-slope.c
@@ -442,6 +442,7 @@ do_slope_benchmark (struct bench_obj *obj)
 	       &overhead);
 
   free (measurement_raw);
+  free (measurements);
   free (real_buffer);
   obj->ops->finalize (obj);
 
@@ -1450,11 +1451,11 @@ bench_mac_init (struct bench_obj *obj)
     }
 
   err = gcry_mac_setkey (hd, key, keylen);
-  free (key);
   if (err)
     {
       fprintf (stderr, PGM ": error setting key for mac `%s'\n",
 	       gcry_mac_algo_name (mode->algo));
+      free (key);
       exit (1);
     }
 
@@ -1473,6 +1474,7 @@ bench_mac_init (struct bench_obj *obj)
 
   obj->priv = hd;
 
+  free (key);
   return 0;
 }
 




More information about the Gcrypt-devel mailing list