From ca5357a65a86b8823bdbf0d6a1c7530cf5cb8aa0 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sat, 23 Mar 2019 12:48:55 +0100 Subject: CppC4Group constructor may throw std::bad_alloc if internal allocation fails --- src/cppc4group.cpp | 5 ++++- src/cppc4group.hpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3-54-g00ecf