Commit 42f5ecd4 authored by Max Kellermann's avatar Max Kellermann

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.
parent 733989a2
No related merge requests found
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment