ICU-9581 Fix some memory leaks in arabic shaping code

X-SVN-Rev: 32491
This commit is contained in:
Michael Ow 2012-10-03 03:32:21 +00:00
parent b56dee8547
commit 8aa34fd449

View file

@ -724,14 +724,15 @@ handleGeneratedSpaces(UChar *dest, int32_t sourceLength,
}
}
if (lamAlefOption || tashkeelOption){
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
if (lamAlefOption || tashkeelOption){
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
i = j = 0; count = 0;
@ -791,16 +792,10 @@ handleGeneratedSpaces(UChar *dest, int32_t sourceLength,
}
if(lamAlefOption || tashkeelOption){
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
i = j = sourceLength; count = 0;
while(i >= 0) {
if ( (lamAlefOption && dest[i] == LAMALEF_SPACE_SUB) ||
(tashkeelOption && dest[i] == TASHKEEL_SPACE_SUB) ){
@ -838,13 +833,6 @@ handleGeneratedSpaces(UChar *dest, int32_t sourceLength,
}
if(lamAlefOption || tashkeelOption){
tempbuffer = (UChar *)uprv_malloc((sourceLength+1)*U_SIZEOF_UCHAR);
/* Test for NULL */
if(tempbuffer == NULL) {
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
uprv_memset(tempbuffer, 0, (sourceLength+1)*U_SIZEOF_UCHAR);
i = j = 0; count = 0;