summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr/node_builder.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h
index 0dd4e44e8..d92524a19 100644
--- a/src/expr/node_builder.h
+++ b/src/expr/node_builder.h
@@ -171,6 +171,7 @@ namespace CVC4 {
#include "base/cvc4_assert.h"
#include "base/output.h"
+#include "base/ptr_closer.h"
#include "expr/kind.h"
#include "expr/metakind.h"
#include "expr/node_value.h"
@@ -887,16 +888,18 @@ Node NodeBuilder<nchild_thresh>::constructNode() const {
template <unsigned nchild_thresh>
Node* NodeBuilder<nchild_thresh>::constructNodePtr() {
- Node *np = new Node(constructNV());
- maybeCheckType(*np);
- return np;
+ // maybeCheckType() can throw an exception. Make sure to call the destructor
+ // on the exception branch.
+ PtrCloser<Node> np(new Node(constructNV()));
+ maybeCheckType(*np.get());
+ return np.release();
}
template <unsigned nchild_thresh>
Node* NodeBuilder<nchild_thresh>::constructNodePtr() const {
- Node *np = new Node(constructNV());
- maybeCheckType(*np);
- return np;
+ PtrCloser<Node> np(new Node(constructNV()));
+ maybeCheckType(*np.get());
+ return np.release();
}
template <unsigned nchild_thresh>
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback