From ec2d3ee159c4314a7282721692d1d49db282b925 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 5 Nov 2017 16:23:46 +0000 Subject: Fix throw in destructors --- project2/common/appInstance.cpp | 4 +--- project2/compression/gzip.cpp | 4 +--- project2/daemon/tempPrivs.cpp | 8 ++------ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/project2/common/appInstance.cpp b/project2/common/appInstance.cpp index 72d34a9..3f8ab58 100644 --- a/project2/common/appInstance.cpp +++ b/project2/common/appInstance.cpp @@ -13,9 +13,7 @@ AppInstance::AppInstance() AppInstance::~AppInstance() { - if (_current != this) { - throw std::runtime_error("All kinds of bad, destroying a non-current AppInstance"); - } + BOOST_ASSERT_MSG(_current == this, "All kinds of bad, destroying a non-current AppInstance"); _current = NULL; } diff --git a/project2/compression/gzip.cpp b/project2/compression/gzip.cpp index 653143f..cbccf40 100644 --- a/project2/compression/gzip.cpp +++ b/project2/compression/gzip.cpp @@ -19,9 +19,7 @@ class GZip : public Decompressor { ~GZip() { inflateEnd(&strm); - if (status != Z_STREAM_END) { - throw std::runtime_error("decompression of stream failed"); - } + BOOST_ASSERT_MSG(status == Z_STREAM_END, "decompression of stream failed"); } void decompress(const char * data, size_t len, const Stream::Sink & sink) { diff --git a/project2/daemon/tempPrivs.cpp b/project2/daemon/tempPrivs.cpp index 9c5edbd..45af498 100644 --- a/project2/daemon/tempPrivs.cpp +++ b/project2/daemon/tempPrivs.cpp @@ -20,14 +20,10 @@ TempPrivs::TempPrivs() : TempPrivs::~TempPrivs() { if (DaemonAppEngine::setUser) { - if (seteuid(originalUid)) { - throw std::runtime_error("Failed restore uid"); - } + BOOST_ASSERT_MSG(!seteuid(originalUid), "Failed restore uid"); } if (DaemonAppEngine::setGroup) { - if (setegid(originalGid)) { - throw std::runtime_error("Failed restore gid"); - } + BOOST_ASSERT_MSG(!setegid(originalGid), "Failed restore gid"); } } -- cgit v1.2.3