mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Fix crash bug from calling eval builtin with no arguments
darcs-hash:20051214134644-ac50b-5872ff628bf4f5d4f22f912d7ce7e9ed25d48b58.gz
This commit is contained in:
parent
de3a28874e
commit
418e26c0ac
32
builtin.c
32
builtin.c
@ -1750,28 +1750,20 @@ static int builtin_status( wchar_t **argv )
|
||||
*/
|
||||
static int builtin_eval( wchar_t **argv )
|
||||
{
|
||||
wchar_t *tot, **ptr, *next;
|
||||
int totlen=0;
|
||||
|
||||
for( ptr = argv+1; *ptr; ptr++ )
|
||||
string_buffer_t sb;
|
||||
int i;
|
||||
int argc = builtin_count_args( argv );
|
||||
sb_init( &sb );
|
||||
|
||||
for( i=1; i<argc; i++ )
|
||||
{
|
||||
totlen += wcslen( *ptr) + 1;
|
||||
sb_append( &sb, argv[i] );
|
||||
sb_append( &sb, L" " );
|
||||
}
|
||||
tot = malloc( sizeof(wchar_t)*totlen );
|
||||
if( !tot )
|
||||
{
|
||||
die_mem();
|
||||
}
|
||||
for( ptr = argv+1, next=tot; *ptr; ptr++ )
|
||||
{
|
||||
int len = wcslen( *ptr );
|
||||
wcscpy( next, *ptr );
|
||||
next+=len;
|
||||
*next++=L' ';
|
||||
}
|
||||
*(next-1)=L'\0';
|
||||
eval( tot, block_io, TOP );
|
||||
free( tot );
|
||||
|
||||
eval( (wchar_t *)sb.buff, block_io, TOP );
|
||||
sb_destroy( &sb );
|
||||
|
||||
return proc_get_last_status();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user