Ignore:
Timestamp:
Oct 8, 2008, 1:39:44 PM (13 years ago)
Author:
charles
Message:

(rpc) extra safeguards in r6867

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r6867 r6868  
    240240        stream.avail_in = content_len;
    241241
     242        /* allocate space for the raw data and call deflate() just once --
     243         * we won't use the deflated data if it's longer than the raw data,
     244         * so it's okay to let deflate() run out of output buffer space */
    242245        evbuffer_expand( out, content_len );
    243246        stream.next_out = EVBUFFER_DATA( out );
     
    245248
    246249        state = deflate( &stream, Z_FINISH );
    247         if( state != Z_STREAM_END )
    248             evbuffer_add( out, content, content_len );
    249         else {
     250
     251        if( state == Z_STREAM_END )
     252        {
    250253            EVBUFFER_LENGTH( out ) = content_len - stream.avail_out;
    251254            tr_ninf( MY_NAME, _( "Deflated response from %zu bytes to %zu" ),
     
    254257            evhttp_add_header( req->output_headers,
    255258                               "Content-Encoding", "deflate" );
     259        }
     260        else
     261        {
     262            evbuffer_drain( out, EVBUFFER_LENGTH( out ) );
     263            evbuffer_add( out, content, content_len );
    256264        }
    257265
Note: See TracChangeset for help on using the changeset viewer.