Skip to content

Commit

Permalink
Merge pull request #4126
Browse files Browse the repository at this point in the history
8d578f1 memwipe: don't call the workhorse for 0 bytes (moneromooo-monero)
  • Loading branch information
luigi1111 committed Jul 27, 2018
2 parents ff01c3a + 8d578f1 commit 21b1fa1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contrib/epee/src/memwipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -67,7 +67,8 @@ void *memwipe(void *ptr, size_t n)

void *memwipe(void *ptr, size_t n)
{
explicit_bzero(ptr, n);
if (n > 0)
explicit_bzero(ptr, n);
SCARECROW
return ptr;
}
Expand Down Expand Up @@ -105,7 +106,8 @@ static void memory_cleanse(void *ptr, size_t len)

void *memwipe(void *ptr, size_t n)
{
memory_cleanse(ptr, n);
if (n > 0)
memory_cleanse(ptr, n);
SCARECROW
return ptr;
}
Expand Down

0 comments on commit 21b1fa1

Please sign in to comment.