Mercurial > dropbear
changeset 163:8e94663164c6 libtommath LTM_DB_0.44
make pointers volatile so that memory zeroing won't get optimised away
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 02 Jan 2005 17:09:26 +0000 |
parents | 3a616069cc21 |
children | c5c969ed76f3 |
files | bn_mp_clear.c |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bn_mp_clear.c Wed Dec 22 16:13:44 2004 +0000 +++ b/bn_mp_clear.c Sun Jan 02 17:09:26 2005 +0000 @@ -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);