Changeset 14088

Show
Ignore:
Timestamp:
03/26/08 12:49:41 (3 months ago)
Author:
tamas
Message:

Fixed CPLResetExtension not to cause memory corruption if the pszPath argument is empty (#2291)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.5/gdal/port/cpl_path.cpp

    r11943 r14088  
    370370    strncpy( pszStaticResult, pszPath, CPL_PATH_BUF_SIZE ); 
    371371    pszStaticResult[CPL_PATH_BUF_SIZE - 1] = '\0'; 
    372     for( i = strlen(pszStaticResult) - 1; i > 0; i--
    373     { 
    374         if( pszStaticResult[i] == '.'
     372    if (*pszStaticResult
     373    { 
     374        for( i = strlen(pszStaticResult) - 1; i > 0; i--
    375375        { 
    376             pszStaticResult[i] = '\0'; 
    377             break; 
     376            if( pszStaticResult[i] == '.' ) 
     377            { 
     378                pszStaticResult[i] = '\0'; 
     379                break; 
     380            } 
     381 
     382            if( pszStaticResult[i] == '/' || pszStaticResult[i] == '\\'  
     383                || pszStaticResult[i] == ':' ) 
     384                break; 
    378385        } 
    379  
    380         if( pszStaticResult[i] == '/' || pszStaticResult[i] == '\\'  
    381             || pszStaticResult[i] == ':' ) 
    382             break; 
    383386    } 
    384387