Index: util/stringutil.c =================================================================== --- util/stringutil.c (revision 999) +++ util/stringutil.c (working copy) @@ -572,17 +572,21 @@ */ unsigned long sqlwchartoul(const SQLWCHAR *wstr) { - const SQLWCHAR *end= wstr + sqlwcharlen(wstr) - 1; + const SQLWCHAR *end; SQLWCHAR c; int pten= 1; unsigned long res= 0; + if (!wstr) return 0; + + /* find the end of the usable digits */ + for (end= wstr; *end && *end >= '0' && *end <= '9'; end++); + end--; + for (; end >= wstr; pten *= 10, end--) { c= *end; - if (c < '0' || c > '9') - return 0; res += (c - '0') * pten; } return res;