spawn: fix crash with command starting with white space

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-06-09 15:59:38 +02:00
parent ae2d037488
commit 20b3330862
1 changed files with 6 additions and 1 deletions

View File

@ -279,7 +279,12 @@ luaA_spawn(lua_State *L)
if(use_sn)
{
char *cmdname, *space;
if((space = strchr(cmd, ' ')))
const char *first_no_space_char = cmd;
/* Look for the first char which is not space */
while(*first_no_space_char && *first_no_space_char == ' ')
first_no_space_char++;
/* Look for space in the string to get the command name. */
if((space = strchr(first_no_space_char, ' ')))
cmdname = a_strndup(cmd, space - cmd);
else
cmdname = a_strdup(cmd);