Merge pull request #4126

8d578f1 memwipe: don't call the workhorse for 0 bytes (moneromooo-monero)
This commit is contained in:
luigi1111 2018-07-27 14:29:55 -05:00
commit 21b1fa1c35
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

View File

@ -50,7 +50,7 @@
void *memwipe(void *ptr, size_t n)
{
if (memset_s(ptr, n, 0, n))
if (n > 0 && memset_s(ptr, n, 0, n))
{
#ifdef NDEBUG
fprintf(stderr, "Error: memset_s failed\n");
@ -67,6 +67,7 @@ void *memwipe(void *ptr, size_t n)
void *memwipe(void *ptr, size_t n)
{
if (n > 0)
explicit_bzero(ptr, n);
SCARECROW
return ptr;
@ -105,6 +106,7 @@ static void memory_cleanse(void *ptr, size_t len)
void *memwipe(void *ptr, size_t n)
{
if (n > 0)
memory_cleanse(ptr, n);
SCARECROW
return ptr;