Am Sunday 16 September 2012 schrieb Niels Möller:
> Tim Ruehsen <[email protected]> writes:
> > Yes, it was some hours of work, but here is a patch that releases all
> > memory and now runs fine with valgrind.
> 
> I've now done the same, in a slightly different manner. I first tried to
> keep the convention that strings are passed as two arguments (length,
> pointer), and tried to make callers always allocate the data, and
> callees always free it. That turned out to be a bit inconvenient in a
> few places. So I rewrote it with a simple string class, and then I could
> just as well put all allocated strings on a linked list to be freed at
> the end.
> 
> I'll try to clean it up and commit it soon.

Looks like you meanwhile comitted it.

There are just two little things left open:
* added mpz_clear in rsa-encrypt.c
* added nettle_buffer_clear, rsa_private_key_clear and free in rsa-keygen.c

Regards, Tim


diff --git a/examples/rsa-encrypt.c b/examples/rsa-encrypt.c
index 70d1503..ca1a8cd 100644
--- a/examples/rsa-encrypt.c
+++ b/examples/rsa-encrypt.c
@@ -253,7 +253,9 @@ main(int argc, char **argv)
     }
 
   write_bignum(stdout, x);
-  
+
+  mpz_clear(x);
+
   if (!process_file(&ctx,
                    stdin, stdout))
     return EXIT_FAILURE;
diff --git a/examples/rsa-keygen.c b/examples/rsa-keygen.c
index 0ca39b4..165e6f4 100644
--- a/examples/rsa-keygen.c
+++ b/examples/rsa-keygen.c
@@ -160,5 +160,12 @@ main(int argc, char **argv)
       return EXIT_FAILURE;
     }
 
+  nettle_buffer_clear(&pub_buffer);
+  nettle_buffer_clear(&priv_buffer);
+  rsa_private_key_clear(&priv);
+  rsa_public_key_clear(&pub);
+  free(pub_name);
+
+
   return EXIT_SUCCESS;
 }
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to