From cb6a5097d77d05418c48ae9c051c7917b97c0fa4 Mon Sep 17 00:00:00 2001 From: markus Date: Fri, 21 Nov 2025 15:20:20 +0100 Subject: [PATCH] Make sure the null terminator len_for_wcs_term is included in the decision to realloc. --- convert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/convert.c b/convert.c index baf647fe..a12262c9 100644 --- a/convert.c +++ b/convert.c @@ -1064,12 +1064,12 @@ setup_getdataclass(SQLLEN * const length_return, const char ** const ptr_return, */ len_for_wcs_term = 1; } - if (changed || needbuflen > cbValueMax) + if (changed || needbuflen + len_for_wcs_term > cbValueMax) { - if (needbuflen > (SQLLEN) pgdc->ttlbuflen) + if (needbuflen + len_for_wcs_term > (SQLLEN) pgdc->ttlbuflen) { pgdc->ttlbuf = realloc(pgdc->ttlbuf, needbuflen + len_for_wcs_term); - pgdc->ttlbuflen = needbuflen; + pgdc->ttlbuflen = needbuflen + len_for_wcs_term; } already_processed = FALSE;