Skip to content

Commit 3c33055

Browse files
authored
Make sure the null terminator len_for_wcs_term is included in the decision to realloc. (#145)
1 parent 6e99e75 commit 3c33055

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

convert.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,12 @@ setup_getdataclass(SQLLEN * const length_return, const char ** const ptr_return,
10641064
*/
10651065
len_for_wcs_term = 1;
10661066
}
1067-
if (changed || needbuflen > cbValueMax)
1067+
if (changed || needbuflen + len_for_wcs_term > cbValueMax)
10681068
{
1069-
if (needbuflen > (SQLLEN) pgdc->ttlbuflen)
1069+
if (needbuflen + len_for_wcs_term > (SQLLEN) pgdc->ttlbuflen)
10701070
{
10711071
pgdc->ttlbuf = realloc(pgdc->ttlbuf, needbuflen + len_for_wcs_term);
1072-
pgdc->ttlbuflen = needbuflen;
1072+
pgdc->ttlbuflen = needbuflen + len_for_wcs_term;
10731073
}
10741074

10751075
already_processed = FALSE;

0 commit comments

Comments
 (0)