Modified:
branches/guffert/driver/unicode.c
Log:
Fix functions that take an SQLPOINTER and a maximum length -- it is in bytes, but we
interpreted it as characters.
Fix sqlchar_as_sqlwchar() to free the correct address when it has made a temporary
allocation.
Modified: branches/guffert/driver/unicode.c
===================================================================
--- branches/guffert/driver/unicode.c 2007-08-30 23:15:27 UTC (rev 719)
+++ branches/guffert/driver/unicode.c 2007-08-30 23:29:00 UTC (rev 720)
@@ -74,7 +74,7 @@
SQLWCHAR *sqlchar_as_sqlwchar(CHARSET_INFO *charset_info, SQLCHAR *str,
SQLINTEGER *len, uint *errors)
{
- SQLCHAR *str_end;
+ SQLCHAR *pos, *str_end;
SQLWCHAR *out;
SQLINTEGER i, out_bytes;
my_bool free_str= FALSE;
@@ -119,16 +119,16 @@
return NULL;
}
- for (i= 0; *str && str < str_end; )
+ for (pos= str, i= 0; *pos && pos < str_end; )
{
if (sizeof(SQLWCHAR) == 4)
{
- str+= utf8toutf32(str, (UTF32 *)(out + i++));
+ pos+= utf8toutf32(pos, (UTF32 *)(out + i++));
}
else
{
UTF32 u32;
- str+= utf8toutf32(str, &u32);
+ pos+= utf8toutf32(pos, &u32);
i+= utf32toutf16(u32, (UTF16 *)(out + i));
}
}
@@ -333,6 +333,9 @@
wvalue= sqlchar_as_sqlwchar(stmt->dbc->cxn_charset_info, value,
&len, &errors);
+ /* char_attr_max is in bytes, we want it in chars. */
+ char_attr_max/= 2;
+
if (len > char_attr_max - 1)
rc= set_error(stmt, MYERR_01004, NULL, 0);
@@ -701,6 +704,9 @@
wvalue= sqlchar_as_sqlwchar(dbc->cxn_charset_info, char_value,
&len, &errors);
+ /* value_max is in bytes, we want it in chars. */
+ value_max/= 2;
+
if (len > value_max - 1)
rc= set_conn_error(dbc, MYERR_01004, NULL, 0);
@@ -802,6 +808,9 @@
default_charset_info,
value, &len, &errors);
+ /* info_max is in bytes, we want it in chars. */
+ info_max/= 2;
+
if (len > info_max - 1)
rc= set_conn_error(dbc, MYERR_01004, NULL, 0);
@@ -925,6 +934,9 @@
default_charset_info),
char_value, &len, &errors);
+ /* value_max is in bytes, we want it in chars. */
+ value_max/= 2;
+
if (len > value_max - 1)
rc= set_conn_error(dbc, MYERR_01004, NULL, 0);
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r720 - branches/guffert/driver | jwinstead | 31 Aug |