Author: wyoung
Date: Thu Mar 15 23:33:48 2007
New Revision: 1439
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1439&view=rev
Log:
For each use of std::string::c_str() where we also use the length()
member to get the true length (i.e. to avoid being confused by nulls)
using data() instead. This should return a pointer to the internal
buffer, or at least as close an approximation as matters. c_str() can
truncate the buffer, since it believes it's being used in a C string
context, which isn't really true in the places we use length().
Modified:
trunk/lib/query.cpp
Modified: trunk/lib/query.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1439&r1=1438&r2=1439&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Thu Mar 15 23:33:48 2007
@@ -94,7 +94,7 @@
bool
Query::exec(const std::string& str)
{
- success_ = !mysql_real_query(&conn_->mysql_, str.c_str(),
+ success_ = !mysql_real_query(&conn_->mysql_, str.data(),
static_cast<unsigned long>(str.length()));
if (!success_ && throw_exceptions()) {
throw BadQuery(error());
@@ -118,7 +118,7 @@
}
else {
// Take str to be the entire query string
- return execute(str.c_str(), str.length());
+ return execute(str.data(), str.length());
}
}
@@ -307,7 +307,7 @@
if (option == 'r' || (option == 'q' && S.is_string)) {
char *s = new char[S.size() * 2 + 1];
- mysql_real_escape_string(&conn_->mysql_, s, S.c_str(),
+ mysql_real_escape_string(&conn_->mysql_, s, S.data(),
static_cast<unsigned long>(S.size()));
SQLString *ss = new SQLString("'");
*ss += s;
@@ -351,7 +351,7 @@
{
const std::string& str(sbuffer_.str());
char* s = new char[str.size() + 1];
- memcpy(s, str.c_str(), str.size() + 1);
+ memcpy(s, str.data(), str.size() + 1);
return s;
}
@@ -416,7 +416,7 @@
}
else {
// Take str to be the entire query string
- return store(str.c_str(), str.length());
+ return store(str.data(), str.length());
}
}
@@ -586,7 +586,7 @@
}
else {
// Take str to be the entire query string
- return use(str.c_str(), str.length());
+ return use(str.data(), str.length());
}
}
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits