summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2019-03-23 12:48:55 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2019-03-23 12:48:55 +0100
commitca5357a65a86b8823bdbf0d6a1c7530cf5cb8aa0 (patch)
treebb38fa1a6439b8e586d59f1666c327f22ea674e2
parentafaebd0407af3f88dfa9c46b74754a1d96f92ab5 (diff)
downloadcc4group-ca5357a65a86b8823bdbf0d6a1c7530cf5cb8aa0.tar.gz
cc4group-ca5357a65a86b8823bdbf0d6a1c7530cf5cb8aa0.zip
CppC4Group constructor may throw std::bad_alloc if internal allocation fails
-rw-r--r--src/cppc4group.cpp5
-rw-r--r--src/cppc4group.hpp1
2 files changed, 5 insertions, 1 deletions
diff --git a/src/cppc4group.cpp b/src/cppc4group.cpp
index 950a714..409f2ef 100644
--- a/src/cppc4group.cpp
+++ b/src/cppc4group.cpp
@@ -22,7 +22,10 @@ struct CppC4Group::Private {
Private() : g{cc4group.new_()}
{
-
+ if(g == nullptr)
+ {
+ throw std::bad_alloc();
+ }
}
Private(CC4Group* g) : g{g}
diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp
index c30af44..eb06585 100644
--- a/src/cppc4group.hpp
+++ b/src/cppc4group.hpp
@@ -101,6 +101,7 @@ public:
public:
// the constructor will automatically construct an internal CC4Group, so no new-equivalent method is needed
+ // may throw std::bad_alloc if the allocation and construction of the internal CC4Group object fails
CppC4Group();
// the move constructor is needed to move the returned group out of the optional from openAsChild