aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/WStringCompare.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-11-06 09:24:18 +0100
committerMax Kellermann <max@duempel.org>2015-11-06 09:24:18 +0100
commit42f5ecd4a116c96d30bf407859dadaa9a053ea39 (patch)
tree644ee945bda37afde922b9a3306fd19c3af23200 /src/util/WStringCompare.cxx
parent733989a284d2f7cce37634b12afad72cc019f659 (diff)
downloadmpd-42f5ecd4a116c96d30bf407859dadaa9a053ea39.tar.gz
mpd-42f5ecd4a116c96d30bf407859dadaa9a053ea39.tar.xz
mpd-42f5ecd4a116c96d30bf407859dadaa9a053ea39.zip
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.
Diffstat (limited to 'src/util/WStringCompare.cxx')
-rw-r--r--src/util/WStringCompare.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util/WStringCompare.cxx b/src/util/WStringCompare.cxx
index 77c3a8629..723f7e47b 100644
--- a/src/util/WStringCompare.cxx
+++ b/src/util/WStringCompare.cxx
@@ -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