diff options
author | lloyd <[email protected]> | 2009-01-31 12:29:53 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-01-31 12:29:53 +0000 |
commit | 3f5c33c9ece2e7373dde96af045cd5a4853697be (patch) | |
tree | 9eb7db0cb7b13d1f55da7ed7fd569e379ae77556 /src | |
parent | 59471d5ad33fc136e0f2c02c9400f50e1515e904 (diff) |
A new warning in glibc triggers if memset is called with a constant size
of 0 (on the theory this is a mistake and the second and third arguments
were swapped). However the GCC inliner apparently is good enough that it
is triggering on code that just happens to create a zero length SecureVector
or equivalent - the constants get propagated so __builtin_constant_p returns
true.
Add an if(n) in clear_mem so we skip calling memset if the size is zero.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/mem_ops.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/utils/mem_ops.h b/src/utils/mem_ops.h index 810356bce..e72269e6a 100644 --- a/src/utils/mem_ops.h +++ b/src/utils/mem_ops.h @@ -1,7 +1,7 @@ -/************************************************* -* Memory Operations Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/* +* Memory Operations Header File +* (C) 1999-2009 Jack Lloyd +*/ #ifndef BOTAN_MEMORY_OPS_H__ #define BOTAN_MEMORY_OPS_H__ @@ -11,14 +11,14 @@ namespace Botan { -/************************************************* -* Memory Manipulation Functions * -*************************************************/ +/* +* Memory Manipulation Functions +*/ template<typename T> inline void copy_mem(T* out, const T* in, u32bit n) { std::memmove(out, in, sizeof(T)*n); } template<typename T> inline void clear_mem(T* ptr, u32bit n) - { std::memset(ptr, 0, sizeof(T)*n); } + { if(n) std::memset(ptr, 0, sizeof(T)*n); } template<typename T> inline void set_mem(T* ptr, u32bit n, byte val) { std::memset(ptr, val, sizeof(T)*n); } |