Date: Friday, January 13, 2006 @ 11:31:32
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/Connection.hpp (1.48 -> 1.49) src/Connection.cpp (1.55
          -> 1.56)

Fixed NULL pointer destruction: was throwing an exception, now does nothing


------------------------+
 include/Connection.hpp |    1 +
 src/Connection.cpp     |   23 +++++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)


Index: carob/include/Connection.hpp
diff -u carob/include/Connection.hpp:1.48 carob/include/Connection.hpp:1.49
--- carob/include/Connection.hpp:1.48   Thu Jan 12 17:33:46 2006
+++ carob/include/Connection.hpp        Fri Jan 13 11:31:32 2006
@@ -204,6 +204,7 @@
    * Deletes given statement.
    * Only way to delete a statement (private dtor) so connection will keep the
    * control of its statement and can remove it from its statement list.
+   * If the given statement pointer is NULL, don't do anything
    * @param stPtr pointer to the statement to destroy
    * @throw DriverException if the given statement is not in our list
    */
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.55 carob/src/Connection.cpp:1.56
--- carob/src/Connection.cpp:1.55       Thu Jan 12 17:33:46 2006
+++ carob/src/Connection.cpp    Fri Jan 13 11:31:32 2006
@@ -246,19 +246,22 @@
 
 void Connection::deleteStatement(Statement* stPtr) throw (DriverException, 
UnexpectedException)
 {
-  for (std::list<Statement*>::iterator iter = created_statements.begin();
-      iter != created_statements.end(); iter++)
+  if (stPtr != NULL) // if null, we don't do anything
   {
-    if (*iter == stPtr)
+    for (std::list<Statement*>::iterator iter = created_statements.begin();
+        iter != created_statements.end(); iter++)
     {
-      created_statements.erase(iter);
-      delete stPtr;
-      return;
-    }
+      if (*iter == stPtr)
+      {
+        created_statements.erase(iter);
+        delete stPtr;
+        return;
+      }
+    }
+    // We shouldn't come here. It means we have been asked to delete a 
statement
+    // we don't own
+    throw DriverException(L"deleteStatement: the given statement is not owned 
by this connection!");
   }
-  // We shouldn't come here. It means we have been asked to delete a statement
-  // we don't own
-  throw DriverException(L"deleteStatement: the given statement is not owned by 
this connection!");
 }
 
 bool Connection::close()

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to