mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix crash bug on invalid input to fish_pager
darcs-hash:20060224184050-ac50b-da122d893fa0e2aabbd48058c696e2815c4657ca.gz
This commit is contained in:
parent
dad2b93d1e
commit
d2e11ea61d
1 changed files with 24 additions and 3 deletions
27
output.c
27
output.c
|
@ -305,10 +305,31 @@ int writembs( char *str )
|
||||||
|
|
||||||
int writech( wint_t ch )
|
int writech( wint_t ch )
|
||||||
{
|
{
|
||||||
static mbstate_t out_state;
|
mbstate_t state;
|
||||||
char buff[MB_CUR_MAX];
|
|
||||||
size_t bytes = wcrtomb( buff, ch, &out_state );
|
|
||||||
int i;
|
int i;
|
||||||
|
char buff[MB_CUR_MAX+1];
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
|
if( ( ch >= ENCODE_DIRECT_BASE) &&
|
||||||
|
( ch < ENCODE_DIRECT_BASE+256) )
|
||||||
|
{
|
||||||
|
buff[0] = ch- ENCODE_DIRECT_BASE;
|
||||||
|
bytes=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset( &state, 0, sizeof(state) );
|
||||||
|
bytes= wcrtomb( buff, ch, &state );
|
||||||
|
|
||||||
|
switch( bytes )
|
||||||
|
{
|
||||||
|
case (size_t)(-1):
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for( i=0; i<bytes; i++ )
|
for( i=0; i<bytes; i++ )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue