ICU-4514 pass 0 length to UnicodeString::releaseBuffer() when the buffer contents is undefined due to a U_FAILURE condition
X-SVN-Rev: 17972
This commit is contained in:
parent
4bb6b2af21
commit
0a0926e58f
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1997-2004, International Business Machines
|
||||
* Copyright (C) 1997-2005, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*
|
||||
@ -745,7 +745,7 @@ Locale::getDisplayLanguage(const Locale &displayLocale,
|
||||
length=uloc_getDisplayLanguage(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
buffer=result.getBuffer(length);
|
||||
@ -757,11 +757,7 @@ Locale::getDisplayLanguage(const Locale &displayLocale,
|
||||
length=uloc_getDisplayLanguage(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.truncate(0);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -789,7 +785,7 @@ Locale::getDisplayScript(const Locale &displayLocale,
|
||||
length=uloc_getDisplayScript(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
buffer=result.getBuffer(length);
|
||||
@ -801,11 +797,7 @@ Locale::getDisplayScript(const Locale &displayLocale,
|
||||
length=uloc_getDisplayScript(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.truncate(0);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -833,7 +825,7 @@ Locale::getDisplayCountry(const Locale &displayLocale,
|
||||
length=uloc_getDisplayCountry(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
buffer=result.getBuffer(length);
|
||||
@ -845,11 +837,7 @@ Locale::getDisplayCountry(const Locale &displayLocale,
|
||||
length=uloc_getDisplayCountry(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.truncate(0);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -877,7 +865,7 @@ Locale::getDisplayVariant(const Locale &displayLocale,
|
||||
length=uloc_getDisplayVariant(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
buffer=result.getBuffer(length);
|
||||
@ -889,11 +877,7 @@ Locale::getDisplayVariant(const Locale &displayLocale,
|
||||
length=uloc_getDisplayVariant(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.truncate(0);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -921,7 +905,7 @@ Locale::getDisplayName(const Locale &displayLocale,
|
||||
length=uloc_getDisplayName(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
buffer=result.getBuffer(length);
|
||||
@ -933,11 +917,7 @@ Locale::getDisplayName(const Locale &displayLocale,
|
||||
length=uloc_getDisplayName(fullName, displayLocale.fullName,
|
||||
buffer, result.getCapacity(),
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.truncate(0);
|
||||
result.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
*************************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1996-2004, International Business Machines Corporation and
|
||||
* Copyright (c) 1996-2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*************************************************************************
|
||||
*/
|
||||
@ -146,7 +146,7 @@ Normalizer::normalize(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
mode, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR) {
|
||||
status=U_ZERO_ERROR;
|
||||
buffer=dest->getBuffer(length);
|
||||
@ -154,7 +154,7 @@ Normalizer::normalize(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
mode, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
}
|
||||
|
||||
if(dest==&localDest) {
|
||||
@ -192,7 +192,7 @@ Normalizer::compose(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
compat, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR) {
|
||||
status=U_ZERO_ERROR;
|
||||
buffer=dest->getBuffer(length);
|
||||
@ -200,7 +200,7 @@ Normalizer::compose(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
compat, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
}
|
||||
|
||||
if(dest==&localDest) {
|
||||
@ -238,7 +238,7 @@ Normalizer::decompose(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
compat, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR) {
|
||||
status=U_ZERO_ERROR;
|
||||
buffer=dest->getBuffer(length);
|
||||
@ -246,7 +246,7 @@ Normalizer::decompose(const UnicodeString& source,
|
||||
source.getBuffer(), source.length(),
|
||||
compat, options,
|
||||
&status);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
|
||||
}
|
||||
|
||||
if(dest==&localDest) {
|
||||
@ -285,7 +285,7 @@ Normalizer::concatenate(UnicodeString &left, UnicodeString &right,
|
||||
buffer, dest->getCapacity(),
|
||||
mode, options,
|
||||
&errorCode);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
errorCode=U_ZERO_ERROR;
|
||||
buffer=dest->getBuffer(length);
|
||||
@ -294,7 +294,7 @@ Normalizer::concatenate(UnicodeString &left, UnicodeString &right,
|
||||
buffer, dest->getCapacity(),
|
||||
mode, options,
|
||||
&errorCode);
|
||||
dest->releaseBuffer(length);
|
||||
dest->releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
if(dest==&localDest) {
|
||||
@ -554,7 +554,7 @@ Normalizer::nextNormalize() {
|
||||
fUMode, fOptions,
|
||||
TRUE, 0,
|
||||
&errorCode);
|
||||
buffer.releaseBuffer(length);
|
||||
buffer.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
errorCode=U_ZERO_ERROR;
|
||||
text->move(text, nextIndex, UITER_ZERO);
|
||||
@ -563,7 +563,7 @@ Normalizer::nextNormalize() {
|
||||
fUMode, fOptions,
|
||||
TRUE, 0,
|
||||
&errorCode);
|
||||
buffer.releaseBuffer(length);
|
||||
buffer.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
nextIndex=text->getIndex(text, UITER_CURRENT);
|
||||
@ -589,7 +589,7 @@ Normalizer::previousNormalize() {
|
||||
fUMode, fOptions,
|
||||
TRUE, 0,
|
||||
&errorCode);
|
||||
buffer.releaseBuffer(length);
|
||||
buffer.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
errorCode=U_ZERO_ERROR;
|
||||
text->move(text, currentIndex, UITER_ZERO);
|
||||
@ -598,7 +598,7 @@ Normalizer::previousNormalize() {
|
||||
fUMode, fOptions,
|
||||
TRUE, 0,
|
||||
&errorCode);
|
||||
buffer.releaseBuffer(length);
|
||||
buffer.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
bufferPos=buffer.length();
|
||||
|
@ -1182,9 +1182,7 @@ MessageFormat::autoQuoteApostrophe(const UnicodeString& pattern, UErrorCode& sta
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
int32_t len = umsg_autoQuoteApostrophe(pat, plen, buf, blen, &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
result.releaseBuffer(len);
|
||||
}
|
||||
result.releaseBuffer(U_SUCCESS(status) ? len : 0);
|
||||
}
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2001-2003, International Business Machines
|
||||
* Copyright (C) 2001-2005, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
@ -166,7 +166,7 @@ void NormalizationTransliterator::handleTransliterate(Replaceable& text, UTransP
|
||||
fMode, 0,
|
||||
TRUE, &neededToNormalize,
|
||||
&errorCode);
|
||||
output.releaseBuffer(length);
|
||||
output.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
|
||||
if(errorCode == U_BUFFER_OVERFLOW_ERROR) {
|
||||
// use a larger output string buffer and do it again from the start
|
||||
@ -177,7 +177,7 @@ void NormalizationTransliterator::handleTransliterate(Replaceable& text, UTransP
|
||||
fMode, 0,
|
||||
TRUE, &neededToNormalize,
|
||||
&errorCode);
|
||||
output.releaseBuffer(length);
|
||||
output.releaseBuffer(U_SUCCESS(errorCode) ? length : 0);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
|
Loading…
Reference in New Issue
Block a user