spawn: fix crash with command starting with white space
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
ae2d037488
commit
20b3330862
7
spawn.c
7
spawn.c
|
@ -279,7 +279,12 @@ luaA_spawn(lua_State *L)
|
||||||
if(use_sn)
|
if(use_sn)
|
||||||
{
|
{
|
||||||
char *cmdname, *space;
|
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);
|
cmdname = a_strndup(cmd, space - cmd);
|
||||||
else
|
else
|
||||||
cmdname = a_strdup(cmd);
|
cmdname = a_strdup(cmd);
|
||||||
|
|
Loading…
Reference in New Issue