Changeset 17693 in webkit


Ignore:
Timestamp:
Nov 9, 2006 1:40:45 PM (17 years ago)
Author:
zbujtas
Message:

2006-11-09 raalexan <rasvan.alexandrescu@nokia.com>

Reviewed by zalan.
DESC: fix brake in chineese variant for google search
http://bugs.webkit.org/show_bug.cgi?id=11414

  • kwq/KWQTextCodec.cpp: (KWQTextDecoder::fromUnicode): (KWQTextDecoder::checkRealloc):
Location:
S60/trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • S60/trunk/WebCore/ChangeLog

    r17676 r17693  
     12006-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
    1112006-11-08  yaharon  <yael.aharon@nokia.com>
    212
  • S60/trunk/WebCore/kwq/KWQTextCodec.cpp

    r17535 r17693  
    6363    QString convertLatin1(const unsigned char *chs, int len);
    6464    static CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iArrayOfCharacterSetsAvailable;
     65    HBufC8* checkRealloc( TPtr8& , TInt );
    6566    TUint iEncoding;
    6667    HBufC8 * iRemainderBuf;
     
    500501
    501502    // 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 );
    504504    TPtr8 ptr( outBuf->Des() );
    505505    ptr.SetLength( 0 );
     
    512512
    513513        // copy result to out buffer
    514         TInt orgLen = ptr.Length();
    515514        if( ptr.Length() + tmpBuf.Length() > ptr.MaxLength() )
    516515            {
    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)
    519519                {
    520                 delete outBuf;
     520                outBuf = temp;
     521                }
     522            else
     523                {
    521524                return QCString("");
    522525                }
     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            {
    523541            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   
    535549    outStr.append( (const char*)( ptr.PtrZ() ) );
    536550    delete outBuf;
     
    538552    return outStr;
    539553    }
     554
     555HBufC8* 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
    540567
    541568QString KWQTextDecoder::windows125xToUnicode( const char *chs, int len )
Note: See TracChangeset for help on using the changeset viewer.