mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 09:30:55 +00:00
sdssplitargs(): now returns NULL only on error.
An empty input string also resulted into the function returning NULL making it harder for the caller to distinguish between error and empty string without checking the original input string length.
This commit is contained in:
parent
1303f02be6
commit
5cabae84e6
@ -480,6 +480,11 @@ int hex_digit_to_int(char c) {
|
|||||||
*
|
*
|
||||||
* Note that sdscatrepr() is able to convert back a string into
|
* Note that sdscatrepr() is able to convert back a string into
|
||||||
* a quoted string in the same format sdssplitargs() is able to parse.
|
* a quoted string in the same format sdssplitargs() is able to parse.
|
||||||
|
*
|
||||||
|
* The function returns the allocated tokens on success, even when the
|
||||||
|
* input string is empty, or NULL if the input contains unbalanced
|
||||||
|
* quotes or closed quotes followed by non space characters
|
||||||
|
* as in: "foo"bar or "foo'
|
||||||
*/
|
*/
|
||||||
sds *sdssplitargs(const char *line, int *argc) {
|
sds *sdssplitargs(const char *line, int *argc) {
|
||||||
const char *p = line;
|
const char *p = line;
|
||||||
@ -576,6 +581,9 @@ sds *sdssplitargs(const char *line, int *argc) {
|
|||||||
(*argc)++;
|
(*argc)++;
|
||||||
current = NULL;
|
current = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
/* Even on empty input string returns something not NULL that
|
||||||
|
* can be freed by sdssplitargs_free. */
|
||||||
|
if (vector == NULL) vector = zmalloc(sizeof(void*));
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user