util/StringCompare: use strncmp() instead of memcmp() in StringStartsWith()
Some optimized implementations of memcmp() may not start from the beginning of the string, and may thus segfault.
This commit is contained in:
parent
733989a284
commit
42f5ecd4a1
@ -36,8 +36,8 @@
|
||||
bool
|
||||
StringStartsWith(const char *haystack, const char *needle)
|
||||
{
|
||||
const size_t length = strlen(needle);
|
||||
return memcmp(haystack, needle, length) == 0;
|
||||
const size_t length = StringLength(needle);
|
||||
return StringIsEqual(haystack, needle, length);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -26,7 +26,8 @@
|
||||
bool
|
||||
StringStartsWith(const wchar_t *haystack, const wchar_t *needle)
|
||||
{
|
||||
return memcmp(haystack, needle, StringLength(needle) * sizeof(needle[0])) == 0;
|
||||
const size_t length = StringLength(needle);
|
||||
return StringIsEqual(haystack, needle, length);
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user