Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
42f5ecd4
Commit
42f5ecd4
authored
Nov 06, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
StringCompare.cxx
src/util/StringCompare.cxx
+2
-2
WStringCompare.cxx
src/util/WStringCompare.cxx
+2
-1
No files found.
src/util/StringCompare.cxx
View file @
42f5ecd4
...
...
@@ -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
...
...
src/util/WStringCompare.cxx
View file @
42f5ecd4
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment