Changeset 5041


Ignore:
Timestamp:
Feb 15, 2008, 2:56:11 PM (14 years ago)
Author:
charles
Message:

ensure tr_info.creator and tr_info.comment are initialized, even if it's only to an empty string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r5034 r5041  
    173173    benc_val_t * beInfo, * val, * val2;
    174174    benc_val_t * meta = (benc_val_t *) meta_in;
     175    char buf[4096];
    175176
    176177    /* info_hash: urlencoded 20-byte SHA1 hash of the value of the info key
     
    197198    savedname( inf->torrent, sizeof( inf->torrent ), inf->hashString, tag );
    198199
    199     /* Comment info */
     200    /* comment */
     201    memset( buf, '\0', sizeof( buf ) );
    200202    val = tr_bencDictFindFirst( meta, "comment.utf-8", "comment", NULL );
    201     if( NULL != val && TYPE_STR == val->type )
    202     {
    203         char buf[4096];
    204         memset( buf, 0, sizeof( buf ) );
     203    if( val && val->type == TYPE_STR )
    205204        strlcat_utf8( buf, val->val.s.s, sizeof( buf ), 0 );
    206         tr_free( inf->comment );
    207         inf->comment = tr_strdup( buf );
    208     }
     205    tr_free( inf->comment );
     206    inf->comment = tr_strdup( buf );
    209207   
    210     /* Creator info */
     208    /* creator */
     209    memset( buf, '\0', sizeof( buf ) );
    211210    val = tr_bencDictFindFirst( meta, "created by.utf-8", "created by", NULL );
    212     if( NULL != val && TYPE_STR == val->type )
    213     {
    214         char buf[4096];
    215         memset( buf, 0, sizeof( buf ) );
     211    if( val && val->type == TYPE_STR )
    216212        strlcat_utf8( buf, val->val.s.s, sizeof( buf ), 0 );
    217         tr_free( inf->creator );
    218         inf->creator = tr_strdup( buf );
    219     }
     213    tr_free( inf->creator );
     214    inf->creator = tr_strdup( buf );
    220215   
    221216    /* Date created */
Note: See TracChangeset for help on using the changeset viewer.