diff options
author | axel <axel@liljencrantz.se> | 2005-12-14 23:46:44 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2005-12-14 23:46:44 +1000 |
commit | 418e26c0ac172c6a1c92cd2d5bdb3e4325bca5aa (patch) | |
tree | dd719b528de28540f30f8845490f8eee6ed20c35 /builtin.c | |
parent | de3a28874e72dde990b56542c54b44c0c0473fe6 (diff) |
Fix crash bug from calling eval builtin with no arguments
darcs-hash:20051214134644-ac50b-5872ff628bf4f5d4f22f912d7ce7e9ed25d48b58.gz
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -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++ ) - { - totlen += wcslen( *ptr) + 1; - } - tot = malloc( sizeof(wchar_t)*totlen ); - if( !tot ) - { - die_mem(); - } - for( ptr = argv+1, next=tot; *ptr; ptr++ ) + string_buffer_t sb; + int i; + int argc = builtin_count_args( argv ); + sb_init( &sb ); + + for( i=1; i<argc; i++ ) { - int len = wcslen( *ptr ); - wcscpy( next, *ptr ); - next+=len; - *next++=L' '; + sb_append( &sb, argv[i] ); + sb_append( &sb, 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(); } |