Changeset 7249


Ignore:
Timestamp:
Dec 3, 2008, 1:25:45 AM (12 years ago)
Author:
charles
Message:

(libT) extra assertions and safeguards for #1523: crash in tr_fdFileCheckout() when starting daemon

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r7131 r7249  
    8282    int             fileExists;
    8383
     84    assert( tor->downloadDir && *tor->downloadDir );
    8485    assert( fileIndex < info->fileCount );
    8586    assert( !file->length || ( fileOffset < file->length ) );
     
    172173    {
    173174        const tr_file * file = &info->files[fileIndex];
    174         const uint64_t  bytesThisPass = MIN( buflen,
    175                                              file->length - fileOffset );
    176 
    177         err = readOrWriteBytes( tor, ioMode,
    178                                 fileIndex, fileOffset, buf, bytesThisPass );
     175        const uint64_t  bytesThisPass = MIN( buflen, file->length - fileOffset );
     176
     177        err = readOrWriteBytes( tor, ioMode, fileIndex, fileOffset, buf, bytesThisPass );
    179178        buf += bytesThisPass;
    180179        buflen -= bytesThisPass;
  • trunk/libtransmission/resume.c

    r7231 r7249  
    462462
    463463    if( ( fieldsToLoad & ( TR_FR_PROGRESS | TR_FR_DOWNLOAD_DIR ) )
    464       && tr_bencDictFindStr( &top, KEY_DOWNLOAD_DIR, &str ) )
     464      && ( tr_bencDictFindStr( &top, KEY_DOWNLOAD_DIR, &str ) )
     465      && ( str && *str ) )
    465466    {
    466467        tr_free( tor->downloadDir );
     
    562563    if( fields & TR_FR_DOWNLOAD_DIR )
    563564    {
    564         const char * downloadDir;
    565         if( !tr_ctorGetDownloadDir( ctor, mode, &downloadDir ) )
     565        const char * path;
     566        if( !tr_ctorGetDownloadDir( ctor, mode, &path ) && path && *path )
    566567        {
    567568            ret |= TR_FR_DOWNLOAD_DIR;
    568569            tr_free( tor->downloadDir );
    569             tor->downloadDir = tr_strdup( downloadDir );
     570            tor->downloadDir = tr_strdup( path );
    570571        }
    571572    }
Note: See TracChangeset for help on using the changeset viewer.