[PPL-devel] [GIT] ppl/ppl(master): Fixed exception safety issue in PIP_Decision_Node copy constructor.

Enea Zaffanella zaffanella at cs.unipr.it
Mon Feb 22 14:44:55 CET 2010


Module: ppl/ppl
Branch: master
Commit: 8ad05a7fa1293c23494ebd8c1a8222c8cc39dc0e
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=8ad05a7fa1293c23494ebd8c1a8222c8cc39dc0e

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Mon Feb 22 14:22:26 2010 +0100

Fixed exception safety issue in PIP_Decision_Node copy constructor.

---

 src/PIP_Tree.cc |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index 56dfb79..d404db7 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -406,15 +406,18 @@ PIP_Decision_Node::PIP_Decision_Node(const PIP_Decision_Node& y)
   : PIP_Tree_Node(y),
     false_child(0),
     true_child(0) {
-  // FIXME: exception safety?
   if (y.false_child != 0) {
     false_child = y.false_child->clone();
     false_child->set_parent(this);
   }
+  // Protect false_child from exception safety issues via std::auto_ptr.
+  std::auto_ptr<PIP_Tree_Node> wrapped_node(false_child);
   if (y.true_child != 0) {
     true_child = y.true_child->clone();
     true_child->set_parent(this);
   }
+  // It is now safe to release false_child.
+  wrapped_node.release();
 }
 
 PIP_Decision_Node::~PIP_Decision_Node() {




More information about the PPL-devel mailing list