Changeset 11806


Ignore:
Timestamp:
Feb 1, 2011, 5:56:19 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3956 "tr_bencFree() could be faster" -- fix memory error.

#3956's r11780 has uncovered a longstanding memory error that occurs when tr_bencParse() fails to parse a dict and leaves a dangling key. This is fixed by cleaning up the key.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r11780 r11806  
    945945nodeInitDict( struct SaveNode * node, const tr_benc * val, tr_bool sort_dicts )
    946946{
    947     int nKeys;
    948947    const int n = val->val.l.count;
     948    const int nKeys = n / 2;
    949949
    950950    assert( tr_bencIsDict( val ) );
    951951
    952     nKeys = n / 2;
    953952    node->val = val;
    954     node->children = tr_new0( int, nKeys * 2 );
     953    node->children = tr_new0( int, n );
    955954
    956955    if( sort_dicts )
     
    975974    else
    976975    {
    977         int i ;
     976        int i;
    978977
    979978        for( i=0; i<n; ++i )
Note: See TracChangeset for help on using the changeset viewer.