Skip to content

Commit

Permalink
Backport fix for CORE-2355 - Incorrect handling of LOWER/UPPER when r…
Browse files Browse the repository at this point in the history
…esult string shrinks in terms of byte length
  • Loading branch information
asfernandes committed Mar 7, 2009
1 parent 1b156fd commit 30a72da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/jrd/evl.cpp
Expand Up @@ -3982,7 +3982,7 @@ static dsc* low_up_case(thread_db* tdbb, const dsc* value, impure_value* impure,
INTL_ASSIGN_TTYPE(&desc, ttype);
EVL_make_value(tdbb, &desc, impure);

intl_str_to_case(tdbb, &impure->vlu_desc);
impure->vlu_desc.dsc_length = (USHORT) intl_str_to_case(tdbb, &impure->vlu_desc);
}

return &impure->vlu_desc;
Expand Down
32 changes: 12 additions & 20 deletions src/jrd/intl.cpp
Expand Up @@ -1194,10 +1194,8 @@ int INTL_str_to_upper(thread_db* tdbb, DSC * pString)
UCHAR* src;
UCHAR buffer[MAX_KEY];
USHORT ttype;
USHORT len =
CVT_get_string_ptr(pString, &ttype, &src,
reinterpret_cast<vary*>(buffer),
sizeof(buffer), ERR_post);
int len = CVT_get_string_ptr(pString, &ttype, &src, reinterpret_cast<vary*>(buffer),
sizeof(buffer), ERR_post);

UCHAR* dest;
switch (ttype) {
Expand All @@ -1216,14 +1214,12 @@ int INTL_str_to_upper(thread_db* tdbb, DSC * pString)

default:
TextType* obj = INTL_texttype_lookup(tdbb, ttype);
obj->str_to_upper(len, src, len, src); // ASF: this works for all cases? (src and dst buffers are the same)
// ASF: this works for all cases? (src and dst buffers are the same)
len = obj->str_to_upper(len, src, len, src);
break;
}
/*
* Added to remove compiler errors. Callers are not checking
* the return code from this function 4/5/95.
*/
return (0);

return len;
}


Expand All @@ -1247,10 +1243,8 @@ int INTL_str_to_lower(thread_db* tdbb, DSC * pString)
UCHAR* src;
UCHAR buffer[MAX_KEY];
USHORT ttype;
USHORT len =
CVT_get_string_ptr(pString, &ttype, &src,
reinterpret_cast<vary*>(buffer),
sizeof(buffer), ERR_post);
int len = CVT_get_string_ptr(pString, &ttype, &src, reinterpret_cast<vary*>(buffer),
sizeof(buffer), ERR_post);

UCHAR* dest;
switch (ttype) {
Expand All @@ -1269,14 +1263,12 @@ int INTL_str_to_lower(thread_db* tdbb, DSC * pString)

default:
TextType* obj = INTL_texttype_lookup(tdbb, ttype);
obj->str_to_lower(len, src, len, src); // ASF: this works for all cases? (src and dst buffers are the same)
// ASF: this works for all cases? (src and dst buffers are the same)
len = obj->str_to_lower(len, src, len, src);
break;
}
/*
* Added to remove compiler errors. Callers are not checking
* the return code from this function 4/5/95.
*/
return (0);

return len;
}


Expand Down

0 comments on commit 30a72da

Please sign in to comment.