Commit bf6c5d96 authored by antirez's avatar antirez
Browse files

Handle a non-impossible empty argv in loadServerConfigFromString().

Usually this does not happens since we trim for " \t\r\n", but if there
are other chars that return true with isspace(), we may end with an
empty argv. Better to handle the condition in an explicit way.
parent 95fc9cc0
...@@ -68,7 +68,7 @@ void loadServerConfigFromString(char *config) { ...@@ -68,7 +68,7 @@ void loadServerConfigFromString(char *config) {
linenum = i+1; linenum = i+1;
lines[i] = sdstrim(lines[i]," \t\r\n"); lines[i] = sdstrim(lines[i]," \t\r\n");
/* Skip comments and blank lines*/ /* Skip comments and blank lines */
if (lines[i][0] == '#' || lines[i][0] == '\0') continue; if (lines[i][0] == '#' || lines[i][0] == '\0') continue;
/* Split into arguments */ /* Split into arguments */
...@@ -77,6 +77,12 @@ void loadServerConfigFromString(char *config) { ...@@ -77,6 +77,12 @@ void loadServerConfigFromString(char *config) {
err = "Unbalanced quotes in configuration line"; err = "Unbalanced quotes in configuration line";
goto loaderr; goto loaderr;
} }
/* Skip this line if the resulting command vector is empty. */
if (argc == 0) {
sdsfreesplitres(argv,argc);
return;
}
sdstolower(argv[0]); sdstolower(argv[0]);
/* Execute config directives */ /* Execute config directives */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment