From d6e39e4d2fde9a86b18ffc1aef53ea9c308feee7 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Fri, 27 May 2011 23:28:40 +0000 Subject: [PATCH] (trunk libT) #4284 "crash via webfrontend or transmission-remote" -- use patch from jerwied --- libtransmission/bencode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libtransmission/bencode.c b/libtransmission/bencode.c index 45ad90ff6..55b98e6bc 100644 --- a/libtransmission/bencode.c +++ b/libtransmission/bencode.c @@ -1265,7 +1265,7 @@ jsonIndent( struct jsonWalk * data ) static void jsonChildFunc( struct jsonWalk * data ) { - if( data->parents ) + if( data->parents && data->parents->data ) { struct ParentState * parentState = data->parents->data; @@ -1372,9 +1372,8 @@ jsonStringFunc( const tr_benc * val, void * vdata ) struct jsonWalk * data = vdata; const unsigned char * it = (const unsigned char *) getStr(val); const unsigned char * end = it + val->val.s.len; - const int safeguard = 512; /* arbitrary margin for escapes and unicode */ - evbuffer_reserve_space( data->out, val->val.s.len+safeguard, vec, 1 ); + evbuffer_reserve_space( data->out, val->val.s.len * 4, vec, 1 ); out = vec[0].iov_base; outend = out + vec[0].iov_len;