VirtualBox

Changeset 1368 in kBuild for trunk/src/lib/nt_fullpath.c


Ignore:
Timestamp:
Dec 7, 2007 7:36:06 PM (17 years ago)
Author:
bird
Message:

don't be optimistic in the cache lookup code, the next component might not exist and we might end up screwing the casing of it this way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt_fullpath.c

    r1265 r1368  
    113113        char *pszLast = &s_szLast[psz - pszPath];
    114114        char *pszCur = psz;
     115        char *pszSrc0 = pszLast;
     116        char *pszDst0 = pszCur;
    115117        for (;;)
    116118        {
     
    119121            if (    ch1 != ch2
    120122                &&  (ch1 != '\\' || ch2 != '/')
    121                 &&  (ch1 != '/'  || ch2 != '\\'))
    122             {
    123                 if (    tolower(ch1) != tolower(ch2)
    124                     &&  toupper(ch1) != toupper(ch2))
    125                     break;
    126                 /* optimistic, component mismatch will be corrected in the next loop. */
    127                 *pszCur = ch2;
    128             }
     123                &&  (ch1 != '/'  || ch2 != '\\')
     124                &&  tolower(ch1) != tolower(ch2)
     125                &&  toupper(ch1) != toupper(ch2))
     126                break;
    129127            if (ch1 == '/' || ch1 == '\\')
    130                 psz = pszCur + 1;
     128            {
     129                                psz = pszCur + 1;
     130                *pszLast = ch1; /* preserve the slashes */
     131            }
    131132            else if (ch1 == '\0')
    132133            {
     
    137138            pszLast++;
    138139        }
     140        if (psz != pszDst0)
     141            memcpy(pszDst0, pszSrc0, psz - pszDst0);
    139142    }
    140143
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette