Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c040cbd6
Commit
c040cbd6
authored
Apr 27, 2011
by
Pieter Noordhuis
Browse files
Check seplen and len before malloc'ing "tokens"
parent
bf9fd5ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
c040cbd6
...
...
@@ -298,15 +298,17 @@ int sdscmp(sds s1, sds s2) {
*/
sds
*
sdssplitlen
(
char
*
s
,
int
len
,
char
*
sep
,
int
seplen
,
int
*
count
)
{
int
elements
=
0
,
slots
=
5
,
start
=
0
,
j
;
sds
*
tokens
;
sds
*
tokens
=
zmalloc
(
sizeof
(
sds
)
*
slots
);
if
(
seplen
<
1
||
len
<
0
)
return
NULL
;
tokens
=
zmalloc
(
sizeof
(
sds
)
*
slots
);
#ifdef SDS_ABORT_ON_OOM
if
(
tokens
==
NULL
)
sdsOomAbort
();
#else
if
(
tokens
==
NULL
)
return
NULL
;
#endif
if
(
seplen
<
1
||
len
<
0
||
tokens
==
NULL
)
{
*
count
=
0
;
return
NULL
;
}
if
(
len
==
0
)
{
*
count
=
0
;
return
tokens
;
...
...
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