Ignore:
Timestamp:
Oct 30, 2008, 7:47:00 PM (13 years ago)
Author:
charles
Message:

(libT) fix a tr_buildPath() bug reported by pea_

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r6982 r6993  
    616616        element = (const char*) va_arg( vl, const char* );
    617617    }
    618     pch = buf = tr_new0( char, bufLen );
     618    pch = buf = tr_new( char, bufLen );
    619619    va_end( vl );
    620620
     
    624624    while( element ) {
    625625        const size_t elementLen = strlen( element );
    626         if( pch != buf )
    627             *pch++ = TR_PATH_DELIMITER;
    628626        memcpy( pch, element, elementLen );
    629627        pch += elementLen;
     628        *pch++ = TR_PATH_DELIMITER;
    630629        element = (const char*) va_arg( vl, const char* );
    631630    }
    632631    va_end( vl );
    633632
     633    /* terminate the string.  if nonempty, eat the unwanted trailing slash */
     634    if( pch != buf )
     635        --pch;
     636    *pch++ = '\0';
     637
    634638    /* sanity checks & return */
    635     *pch++ = '\0';
    636639    assert( pch - buf == (off_t)bufLen );
    637640    return buf;
Note: See TracChangeset for help on using the changeset viewer.