Check for null pointer before applying memwipe()

This commit is contained in:
Andreas Steffen 2015-02-02 11:36:14 +01:00
parent c2aca9eed2
commit bfb708ea23
1 changed files with 10 additions and 4 deletions

View File

@ -643,10 +643,16 @@ METHOD(private_key_t, destroy, void,
if (ref_put(&this->ref))
{
lib->encoding->clear_cache(lib->encoding, this);
memwipe(this->s1, this->set->n * sizeof(int8_t));
memwipe(this->s2, this->set->n * sizeof(int8_t));
free(this->s1);
free(this->s2);
if (this->s1)
{
memwipe(this->s1, this->set->n * sizeof(int8_t));
free(this->s1);
}
if (this->s2)
{
memwipe(this->s2, this->set->n * sizeof(int8_t));
free(this->s2);
}
free(this->A);
free(this);
}