Check for null pointer before applying memwipe()
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 2 Feb 2015 10:36:14 +0000 (11:36 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 25 Feb 2015 20:45:34 +0000 (21:45 +0100)
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);
        }