(trunk, libT) fix code in the UTF8-to-JSON serializer that could fall into an infinite loop when fed some inputs. This may be ticket #2326 or may get its own retroactive ticket, depending on feedback from #2326's reporter

This commit is contained in:
Charles Kerr 2009-09-02 15:26:34 +00:00
parent 5304a133ac
commit 515a3f986f
1 changed files with 1 additions and 3 deletions

View File

@ -1339,9 +1339,7 @@ jsonStringFunc( const tr_benc * val, void * vdata )
UTF32 buf = 0;
UTF32 * u32 = &buf;
ConversionResult result = ConvertUTF8toUTF32( &tmp, end, &u32, &buf + 1, 0 );
if( ( result != conversionOK ) && ( tmp == it ) )
++it; /* it's beyond help; skip it */
else {
if((( result==conversionOK ) || (result==targetExhausted)) && (tmp!=it)) {
evbuffer_add_printf( data->out, "\\u%04x", (unsigned int)buf );
it = tmp - 1;
}