VirtualBox

Changeset 96258 in vbox


Ignore:
Timestamp:
Aug 17, 2022 11:02:48 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt: strstr fix. bugref:10261

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strstr.cpp

    r96043 r96258  
    4545{
    4646    char const  ch0Sub = *pszSubStr;
    47     pszString = strchr(pszString, ch0Sub);
    48     if (pszString)
     47    if (ch0Sub != '\0')
    4948    {
    50         size_t const cchSubStr = strlen(pszSubStr);
    51         do
     49        pszString = strchr(pszString, ch0Sub);
     50        if (pszString)
    5251        {
    53             if (strncmp(pszString, pszSubStr, cchSubStr) == 0)
    54                 return (char *)pszString;
    55             if (ch0Sub)
    56                 pszString = strchr(pszString + 1, ch0Sub);
    57             else
    58                 break;
    59         } while (pszString != NULL);
     52            size_t const cchSubStr = strlen(pszSubStr);
     53            do
     54            {
     55                if (strncmp(pszString, pszSubStr, cchSubStr) == 0)
     56                    return (char *)pszString;
     57                if (ch0Sub)
     58                    pszString = strchr(pszString + 1, ch0Sub);
     59                else
     60                    break;
     61            } while (pszString != NULL);
     62        }
     63        return NULL;
    6064    }
    61     return NULL;
     65    return (char *)pszString;
    6266}
    6367RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strstr);
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r95044 r96258  
    11211121        const char *pszRet = expr; \
    11221122        if (pszRet != NULL) \
    1123             RTTestFailed(hTest, "%d: %#x -> %s expected NULL", __LINE__, #expr, pszRet); \
     1123            RTTestFailed(hTest, "%d: %s -> %s expected NULL", __LINE__, #expr, pszRet); \
    11241124    } while (0)
    11251125
    11261126#define CHECK(expr, expect) \
    11271127    do { \
    1128         const char *pszRet = expr; \
    1129         const char *pszExpect = (expect); \
     1128        const char * const pszRet = expr; \
     1129        const char * const pszExpect = (expect); \
    11301130        if (   (pszRet != NULL && pszExpect == NULL) \
    11311131            || (pszRet == NULL && pszExpect != NULL) \
    11321132            || strcmp(pszRet, pszExpect) \
    11331133            ) \
    1134             RTTestFailed(hTest, "%d: %#x -> %s expected %s", __LINE__, #expr, pszRet, pszExpect); \
     1134            RTTestFailed(hTest, "%d: %s -> %s expected %s", __LINE__, #expr, pszRet, pszExpect); \
    11351135    } while (0)
    11361136
Note: See TracChangeset for help on using the changeset viewer.

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