Date: Monday, March 6, 2006 @ 11:18:49
Author: csaba
Path: /cvsroot/carob/libmysequoia/src
Modified: CarobMySQL.cpp (1.59 -> 1.60)
Put the end of string '\0' when len=2*length
----------------+
CarobMySQL.cpp | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
Index: libmysequoia/src/CarobMySQL.cpp
diff -u libmysequoia/src/CarobMySQL.cpp:1.59
libmysequoia/src/CarobMySQL.cpp:1.60
--- libmysequoia/src/CarobMySQL.cpp:1.59 Fri Mar 3 13:39:34 2006
+++ libmysequoia/src/CarobMySQL.cpp Mon Mar 6 11:18:49 2006
@@ -1084,10 +1084,8 @@
CarobMYSQL::real_escape_string (char *to, const char *from, unsigned long
length)
{
wstring w = to_wstring(string(from, length));
- LOG4CXX_DEBUG(logger, "alma0 " << from << ":" << length);
- LOG4CXX_DEBUG(logger, "alma1 " << from_wstring(w));
- wstring r;
std::wstring::const_iterator i = w.begin();
+ wstring r;
wchar_t esc;
for (; i != w.end(); i++)
@@ -1113,11 +1111,12 @@
r.push_back(*i);
}
}
- r.push_back(L'\0');
- LOG4CXX_DEBUG(logger, "alma22 " << r.length());
string s = from_wstring(r);
- LOG4CXX_DEBUG(logger, "alma2 " << s << ":" << s.length());
- memcpy(to, s.data(), s.length() < 2*length ? s.length() : 2*length);
+
+ size_t len = s.length() < 2*length ? s.length() : 2*length-1;
+ memcpy(to, s.data(), len);
+ to[len] = 0;
+
return (s.length() < 2*length) ? (unsigned long) (s.length()) : (unsigned
long) ~0;
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits