(trunk libT) #1832: Transmission should notify when JSON parser fails

This commit is contained in:
Charles Kerr 2009-02-27 00:57:42 +00:00
parent 074b2327e7
commit 288f38e1fb
1 changed files with 13 additions and 2 deletions

View File

@ -144,6 +144,8 @@ tr_jsonParse( const void * vbuf,
tr_benc * setme_benc,
const uint8_t ** setme_end )
{
int line = 1;
int column = 1;
int err = 0;
const unsigned char * buf = vbuf;
const void * bufend = buf + len;
@ -162,11 +164,20 @@ tr_jsonParse( const void * vbuf,
data.stack = TR_PTR_ARRAY_INIT;
checker = new_JSON_parser( &config );
while( ( buf != bufend ) && JSON_parser_char( checker, *buf ) )
while( ( buf != bufend ) && JSON_parser_char( checker, *buf ) ) {
if( *buf != '\n' )
++column;
else {
++line;
column = 1;
}
++buf;
}
if( buf != bufend )
if( buf != bufend ) {
tr_err( "JSON parser failed at line %d, column %d: \"%.16s\"", line, column, buf );
err = EILSEQ;
}
if( !data.hasContent )
err = EINVAL;