Skip to content

Commit

Permalink
Some amendments to ODBC-51 patch on *nix.
Browse files Browse the repository at this point in the history
Also connector returned 0 as available string length
in case if application did not provide buffer for it.
  • Loading branch information
lawrinn committed Sep 8, 2016
1 parent 6b41841 commit 05206c8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ma_platform_posix.c
Expand Up @@ -214,9 +214,9 @@ char *MADB_ConvertFromWChar(SQLWCHAR *Ptr, SQLINTEGER PtrLength, SQLULEN *Length

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

if (AscLen != (size_t)-1 && AscLen != 0)
if (AscLen != (size_t)-1)
{
if (PtrLength == -1)
if (PtrLength == -1 && AscLen > 0)
{
--AscLen;
}
Expand Down Expand Up @@ -345,7 +345,11 @@ SQLLEN MADB_SetString(Client_Charset* cc, void *Dest, SQLULEN DestLength,
else
{
Length= MbstrCharLen(Src, SrcLength, cc->cs_info);
return Length;

/* In case of !DestLength || !Dest(application didn't give buffer and probably wants to know required length)
* we most probably have empty Src, and Length will be equal 0 in this case.
* Taking source length as character length. MultiByteToWideChar on windows does that for us */
return Length == 0 && SrcLength > 0 ? SrcLength : Length;
}
}

Expand Down

0 comments on commit 05206c8

Please sign in to comment.