Changeset 6348


Ignore:
Timestamp:
Jul 16, 2008, 10:45:28 PM (13 years ago)
Author:
charles
Message:

(daemon) plug some minor memory leaks reported by softwareelves

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r6329 r6348  
    7272saveState( tr_session * s )
    7373{
     74    int i, n = 0;
     75    char * strs[4];
     76
    7477    tr_benc d;
    7578    if( tr_bencLoadJSONFile( myConfigFilename, &d ) )
     
    8285    replaceInt( &d, KEY_PORT_FORWARDING, tr_sessionIsPortForwardingEnabled( s ) );
    8386    replaceInt( &d, KEY_PEX_ENABLED,     tr_sessionIsPexEnabled( s ) );
    84     replaceStr( &d, KEY_USERNAME,        tr_sessionGetRPCUsername( s ) );
    85     replaceStr( &d, KEY_PASSWORD,        tr_sessionGetRPCPassword( s ) );
    86     replaceStr( &d, KEY_ACL,             tr_sessionGetRPCACL( s ) );
     87    replaceStr( &d, KEY_USERNAME,        strs[n++] = tr_sessionGetRPCUsername( s ) );
     88    replaceStr( &d, KEY_PASSWORD,        strs[n++] = tr_sessionGetRPCPassword( s ) );
     89    replaceStr( &d, KEY_ACL,             strs[n++] = tr_sessionGetRPCACL( s ) );
    8790    replaceInt( &d, KEY_RPC_PORT,        tr_sessionGetRPCPort( s ) );
    8891    replaceInt( &d, KEY_AUTH_REQUIRED,   tr_sessionIsRPCPasswordEnabled( s ) );
     
    9699    tr_bencFree( &d );
    97100    tr_ninf( MY_NAME, "saved \"%s\"", myConfigFilename );
     101
     102    for( i=0; i<n; ++i )
     103        tr_free( strs[i] );
    98104}
    99105
     
    344350    int authRequired = -1;
    345351    int blocklistEnabled = -1;
     352    char * freeme = NULL;
    346353    const char * configDir = NULL;
    347354    const char * downloadDir = NULL;
     
    360367              &blocklistEnabled );
    361368    if( configDir == NULL )
    362         configDir = tr_strdup_printf( "%s-daemon", tr_getDefaultConfigDir() );
     369        configDir = freeme = tr_strdup_printf( "%s-daemon", tr_getDefaultConfigDir() );
    363370    tr_buildPath( myConfigFilename, sizeof( myConfigFilename ),
    364371                  configDir, CONFIG_FILE, NULL );
     
    383390    printf( " done.\n" );
    384391
     392    tr_free( freeme );
    385393    return 0;
    386394}
Note: See TracChangeset for help on using the changeset viewer.