From 59b0174a5e68a8686bb4b7cea1cd1d70ac232473 Mon Sep 17 00:00:00 2001 From: Matt Johnston <matt@ucc.asn.au> Date: Sun, 2 Jan 2005 17:09:26 +0000 Subject: [PATCH] make pointers volatile so that memory zeroing won't get optimised away --HG-- branch : libtommath extra : convert_revision : e0186764b7d023da96c6f248b0378af701d3c7c4 --- bn_mp_clear.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bn_mp_clear.c b/bn_mp_clear.c index 53426480..1dc053b7 100644 --- a/bn_mp_clear.c +++ b/bn_mp_clear.c @@ -19,14 +19,17 @@ void mp_clear (mp_int * a) { - int i; + volatile mp_digit *p; + int len; /* only do anything if a hasn't been freed previously */ if (a->dp != NULL) { /* first zero the digits */ - for (i = 0; i < a->used; i++) { - a->dp[i] = 0; - } + len = a->alloc; + p = a->dp; + while (len--) { + *p++ = 0; + } /* free ram */ XFREE(a->dp); -- GitLab