mirror of
https://github.com/fluencelabs/redis
synced 2025-05-01 21:42:13 +00:00
Check seplen and len before malloc'ing "tokens"
This commit is contained in:
parent
355d8cb0b5
commit
6e258c76bf
@ -296,12 +296,17 @@ int sdscmp(sds s1, sds s2) {
|
|||||||
*/
|
*/
|
||||||
sds *sdssplitlen(char *s, int len, char *sep, int seplen, int *count) {
|
sds *sdssplitlen(char *s, int len, char *sep, int seplen, int *count) {
|
||||||
int elements = 0, slots = 5, start = 0, j;
|
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
|
#ifdef SDS_ABORT_ON_OOM
|
||||||
if (tokens == NULL) sdsOomAbort();
|
if (tokens == NULL) sdsOomAbort();
|
||||||
|
#else
|
||||||
|
if (tokens == NULL) return NULL;
|
||||||
#endif
|
#endif
|
||||||
if (seplen < 1 || len < 0 || tokens == NULL) return NULL;
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
*count = 0;
|
*count = 0;
|
||||||
return tokens;
|
return tokens;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user