Check for null pointer before applying memwipe()
[strongswan.git] / src / libstrongswan / plugins / bliss / bliss_private_key.c
index 64f0b06..0f89bed 100644 (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);
        }