Skip to content

Commit

Permalink
Added nullptr check in Ctxt destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
gizemscetin committed Jul 12, 2018
1 parent ec47abb commit 150468b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions cufhe/lib/cufhe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,23 @@ PubKey::~PubKey() {
}

Ctxt::~Ctxt() {
lwe_sample_deleter_(lwe_sample_->data());
lwe_sample_deleter_ = nullptr;
lwe_sample_->set_data(nullptr);
delete lwe_sample_;
lwe_sample_ = nullptr;

lwe_sample_device_deleter_(lwe_sample_device_->data());
lwe_sample_device_deleter_ = nullptr;
lwe_sample_device_->set_data(nullptr);
delete lwe_sample_device_;
lwe_sample_device_ = nullptr;
if(lwe_sample_ != nullptr)
{
lwe_sample_deleter_(lwe_sample_->data());
lwe_sample_deleter_ = nullptr;
lwe_sample_->set_data(nullptr);
delete lwe_sample_;
lwe_sample_ = nullptr;
}

if(lwe_sample_device_ != nullptr)
{
lwe_sample_device_deleter_(lwe_sample_device_->data());
lwe_sample_device_deleter_ = nullptr;
lwe_sample_device_->set_data(nullptr);
delete lwe_sample_device_;
lwe_sample_device_ = nullptr;
}
}

void SetSeed(uint32_t seed) {
Expand Down

0 comments on commit 150468b

Please sign in to comment.