Browse Source

Fix assertion on uClibc when the argv is empty

git-svn-id: https://klish.googlecode.com/svn/trunk@414 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
b2e1cdafff
1 changed files with 6 additions and 5 deletions
  1. 6 5
      lub/argv/argv_new.c

+ 6 - 5
lub/argv/argv_new.c

@@ -16,16 +16,17 @@ static void lub_argv_init(lub_argv_t * this, const char *line, size_t offset)
 	lub_arg_t *arg;
 	bool_t quoted;
 
-	if (!line) {
-		this->argv = NULL;
-		this->argc = 0;
+	this->argv = NULL;
+	this->argc = 0;
+	if (!line)
 		return;
-	}
 	/* first of all count the words in the line */
 	this->argc = lub_argv_wordcount(line);
+	if (0 == this->argc)
+		return;
 	/* allocate space to hold the vector */
 	arg = this->argv = malloc(sizeof(lub_arg_t) * this->argc);
-		assert(arg);
+	assert(arg);
 
 	/* then fill out the array with the words */
 	for (word = lub_argv_nextword(line, &len, &offset, &quoted);