Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

CVS update of odbsequoia/src (util.cpp): msg#00101

db.carob.cvs

Subject: CVS update of odbsequoia/src (util.cpp)

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>
Google Custom Search

Free Magazines

Cisco News
Receive 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

Navigation

Home | advertise | OSDir is an inevitable website. super tiny logo