|
|
Choosing A Webhost: |
CVS update of odbsequoia/src (util.cpp): msg#00101db.carob.cvs
Date: Monday, March 20, 2006 @ 22:07:43 Author: marc Path: /cvsroot/carob/odbsequoia/src Modified: util.cpp (1.3 -> 1.4) Now toSQLW() is also handling an null outsize pointer and an empty buffer. ----------+ util.cpp | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) Index: odbsequoia/src/util.cpp diff -u odbsequoia/src/util.cpp:1.3 odbsequoia/src/util.cpp:1.4 --- odbsequoia/src/util.cpp:1.3 Thu Jan 19 18:34:08 2006 +++ odbsequoia/src/util.cpp Mon Mar 20 22:07:43 2006 @@ -91,7 +91,15 @@ toSQLW(const std::wstring& in, SQLWCHAR * const outbuf, const SQLLEN bufsize, SQLLEN * outsize) { - + // no space at all! + if (bufsize < 1) { + if (outsize) + *outsize = 0; + // "truncated" since we don't even have the room for the + // terminator + return true; + } + // See explanations in fromSQLW(...) above if (sizeof(wchar_t) == sizeof(SQLWCHAR)) { @@ -100,8 +108,9 @@ } else { // minus one for the trailing zero. We want enough room for a - // SQLWCHAR zero, not just for a byte zero. - SQLWCHAR * const outbuf_end = outbuf + bufsize - 1; + // SQLWCHAR zero, not just for a byte zero, so be careful with + // those parentheses! + SQLWCHAR * const outbuf_end = (outbuf + bufsize) - 1; std::wstring::const_iterator src = in.begin(); SQLWCHAR * dst = outbuf; @@ -112,8 +121,11 @@ dst++; src++; } + // Null terminates the array *dst = 0; - *outsize = dst - outbuf; + + if (outsize) + *outsize = dst - outbuf; if (src != in.end()) return true;
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of odbsequoia/src (stmt.cpp stmt.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of odbsequoia/src (descriptors_records.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/include (3 files), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of odbsequoia/src (util.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|