Skip to content

Commit 05206c8

Browse files
committed
Some amendments to ODBC-51 patch on *nix.
Also connector returned 0 as available string length in case if application did not provide buffer for it.
1 parent 6b41841 commit 05206c8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ma_platform_posix.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ char *MADB_ConvertFromWChar(SQLWCHAR *Ptr, SQLINTEGER PtrLength, SQLULEN *Length
214214

215215
AscLen= mariadb_convert_string((char*)Ptr, &PtrOctetLen, utf16, AscStr, &AscLen, cc->cs_info, Error);
216216

217-
if (AscLen != (size_t)-1 && AscLen != 0)
217+
if (AscLen != (size_t)-1)
218218
{
219-
if (PtrLength == -1)
219+
if (PtrLength == -1 && AscLen > 0)
220220
{
221221
--AscLen;
222222
}
@@ -345,7 +345,11 @@ SQLLEN MADB_SetString(Client_Charset* cc, void *Dest, SQLULEN DestLength,
345345
else
346346
{
347347
Length= MbstrCharLen(Src, SrcLength, cc->cs_info);
348-
return Length;
348+
349+
/* In case of !DestLength || !Dest(application didn't give buffer and probably wants to know required length)
350+
* we most probably have empty Src, and Length will be equal 0 in this case.
351+
* Taking source length as character length. MultiByteToWideChar on windows does that for us */
352+
return Length == 0 && SrcLength > 0 ? SrcLength : Length;
349353
}
350354
}
351355

0 commit comments

Comments
 (0)