8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 05:23:03 +01:00

Backport fix for CORE-3479 - ASCII_VAL raises error instead of return 0 for empty strings.

This commit is contained in:
asfernandes 2011-06-04 18:42:37 +00:00
parent ce5be1f386
commit c644ccd699
2 changed files with 16 additions and 4 deletions

View File

@ -49,6 +49,11 @@
Contributor(s):
Alex Peshkov <peshkoff at mail.ru>
* Bugfix CORE-3479
ASCII_VAL raises error instead of return 0 for empty strings.
Contributor(s):
Adriano dos Santos Fernandes <adrianosf at uol.com.br>
* Bugfix CORE-3477
Passing non-existing SQL parameters always crash server
Contributor(s):

View File

@ -1153,12 +1153,19 @@ dsc* evlAsciiVal(Jrd::thread_db* tdbb, const SysFunction*, Jrd::jrd_nod* args,
UCHAR* p;
MoveBuffer temp;
int length = MOV_make_string2(tdbb, value, value->getCharSet(), &p, temp);
UCHAR dummy[4];
if (cs->substring(length, p, sizeof(dummy), dummy, 0, 1) != 1)
status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_transliteration_failed));
if (length == 0)
impure->vlu_misc.vlu_short = 0;
else
{
UCHAR dummy[4];
if (cs->substring(length, p, sizeof(dummy), dummy, 0, 1) != 1)
status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_transliteration_failed));
impure->vlu_misc.vlu_short = p[0];
}
impure->vlu_misc.vlu_short = (length > 0 ? p[0] : 0);
impure->vlu_desc.makeShort(0, &impure->vlu_misc.vlu_short);
return &impure->vlu_desc;