Return the required SQLGetInfo buffer size in bytes not characters to prevent memory...
authorDave Page <dpage@pgadmin.org>
Fri, 16 Jul 2004 07:52:55 +0000 (07:52 +0000)
committerDave Page <dpage@pgadmin.org>
Fri, 16 Jul 2004 07:52:55 +0000 (07:52 +0000)
info.c
info30.c

diff --git a/info.c b/info.c
index a199fc4d33c072f8022644889982111772c0ef23..1737fb974116a8f3f1d8dc000417c4743655994e 100644 (file)
--- a/info.c
+++ b/info.c
@@ -746,6 +746,14 @@ PGAPI_GetInfo(
    {
        /* char/binary data */
        len = strlen(p);
+                
+                /* Note that at this point we don't know if we've been called just
+                 * to get the length of the output. If it's unicode, then we better
+                 * adjust to bytes now, so we don't return a buffer size that's too
+                 * small.
+                 */
+                if (conn->unicode)
+                    len *= WCLEN;
 
        if (rgbInfoValue)
        {
@@ -762,7 +770,7 @@ PGAPI_GetInfo(
            if (len >= cbInfoValueMax)
            {
                result = SQL_SUCCESS_WITH_INFO;
-               CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for tthe InfoValue.");
+               CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the InfoValue.");
            }
        }
    }
index bb784f0a10e532106e5d4838a218a63b03f34381..9496b9569c13c9cf957321412439dcb6425121bb 100644 (file)
--- a/info30.c
+++ b/info30.c
@@ -363,6 +363,14 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
        /* char/binary data */
        len = strlen(p);
 
+                /* Note that at this point we don't know if we've been called just
+                 * to get the length of the output. If it's unicode, then we better
+                 * adjust to bytes now, so we don't return a buffer size that's too
+                 * small.
+                 */
+                if (conn->unicode)
+                    len *= WCLEN;
+                
        if (rgbInfoValue)
        {
 #ifdef UNICODE_SUPPORT
@@ -378,7 +386,7 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
            if (len >= cbInfoValueMax)
            {
                result = SQL_SUCCESS_WITH_INFO;
-               CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for tthe InfoValue.");
+               CC_set_error(conn, CONN_TRUNCATED, "The buffer was too small for the InfoValue.");
            }
        }
    }