Author: wyoung
Date: Mon Jun 26 20:21:27 2006
New Revision: 1296
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1296&view=rev
Log:
Fixed a potential memory leak in the conversion of built-up queries to
simple strings. I.e. such as when calling str().
Modified:
trunk/lib/query.cpp
Modified: trunk/lib/query.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1296&r1=1295&r2=1296&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Mon Jun 26 20:21:27 2006
@@ -262,6 +262,7 @@
if (replace) {
S = *ss;
S.processed = true;
+ delete ss;
return &S;
}
else {
@@ -274,6 +275,7 @@
if (replace) {
S = *ss;
S.processed = true;
+ delete ss;
return &S;
}
else {
@@ -324,7 +326,11 @@
}
ss = pprepare(i->option, (*c)[num], c->bound());
dynamic_cast<std::ostream&>(*this) << *ss;
- if (ss != &(*c)[num]) {
+ if (!c->bound()) {
+ // Returned pointer is to dynamically allocated
object,
+ // so it's our responsibility to release it.
(The other
+ // possibility is that pprepare() simply
overwrote
+ // (*c)[num], instead of allocating new memory.)
delete ss;
}
}
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits