Changeset 17693 in webkit
- Timestamp:
- Nov 9, 2006 1:40:45 PM (17 years ago)
- Location:
- S60/trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
S60/trunk/WebCore/ChangeLog
r17676 r17693 1 2006-11-09 raalexan <rasvan.alexandrescu@nokia.com> 2 3 Reviewed by zalan. 4 DESC: fix brake in chineese variant for google search 5 http://bugs.webkit.org/show_bug.cgi?id=11414 6 7 * kwq/KWQTextCodec.cpp: 8 (KWQTextDecoder::fromUnicode): 9 (KWQTextDecoder::checkRealloc): 10 1 11 2006-11-08 yaharon <yael.aharon@nokia.com> 2 12 -
S60/trunk/WebCore/kwq/KWQTextCodec.cpp
r17535 r17693 63 63 QString convertLatin1(const unsigned char *chs, int len); 64 64 static CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iArrayOfCharacterSetsAvailable; 65 HBufC8* checkRealloc( TPtr8& , TInt ); 65 66 TUint iEncoding; 66 67 HBufC8 * iRemainderBuf; … … 500 501 501 502 // guess the size of out buffer, try to minimize reallocation 502 // the last added 1 is for the ptr which is zeroed later 503 HBufC8* outBuf = HBufC8::NewMaxL( str.length() * 2 + 1 + 1 ); 503 HBufC8* outBuf = HBufC8::NewMaxL( str.length() * 2 + 1 ); 504 504 TPtr8 ptr( outBuf->Des() ); 505 505 ptr.SetLength( 0 ); … … 512 512 513 513 // copy result to out buffer 514 TInt orgLen = ptr.Length();515 514 if( ptr.Length() + tmpBuf.Length() > ptr.MaxLength() ) 516 515 { 517 HBufC8* temp = outBuf->ReAlloc( ptr.MaxLength() + tmpBuf.MaxLength() ); 518 if( !temp ) 516 HBufC8* temp = checkRealloc( ptr, (ptr.MaxLength() + tmpBuf.MaxLength()) ); 517 delete outBuf; 518 if(temp) 519 519 { 520 delete outBuf; 520 outBuf = temp; 521 } 522 else 523 { 521 524 return QCString(""); 522 525 } 526 } 527 528 ptr.Append( tmpBuf ); 529 530 if( ret == 0 ) break; 531 inBuf.Set( inBuf.Right( ret ) ); 532 } 533 534 //check if realloc needs for zero terminated string 535 if(ptr.MaxLength() == ptr.Length()) 536 { 537 HBufC8* temp = checkRealloc( ptr, ptr.MaxLength() + 1); 538 delete outBuf; 539 if(temp) 540 { 523 541 outBuf = temp; 524 ptr.Set( outBuf->Des() ); 525 ptr.SetLength( orgLen ); 526 } 527 528 ptr.Append( tmpBuf ); 529 530 if( ret == 0 ) break; 531 532 inBuf.Set( inBuf.Right( ret ) ); 533 } 534 542 } 543 else 544 { 545 return QCString(""); 546 } 547 } 548 535 549 outStr.append( (const char*)( ptr.PtrZ() ) ); 536 550 delete outBuf; … … 538 552 return outStr; 539 553 } 554 555 HBufC8* KWQTextDecoder::checkRealloc( TPtr8& aPtr, TInt aLen ) 556 { 557 HBufC8* outBuf = HBufC8::NewMax( aLen ); 558 if(outBuf) 559 { 560 outBuf->Des().Copy( aPtr ); 561 aPtr.Set( outBuf->Des() ); 562 aPtr.SetLength( aLen ); 563 } 564 return outBuf; 565 } 566 540 567 541 568 QString KWQTextDecoder::windows125xToUnicode( const char *chs, int len )
Note: See TracChangeset
for help on using the changeset viewer.