From e2ed5d0977239684b679142c8704a6f94eb4f5dc Mon Sep 17 00:00:00 2001 From: axel Date: Fri, 9 Dec 2005 12:40:34 +1000 Subject: [PATCH] Fix buffer inconsistency un ^U darcs-hash:20051209024034-ac50b-a06c78f8f238f61c99ddcd4bee02f8b41af26c6c.gz --- reader.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reader.c b/reader.c index 9b2b1ad37..7c66d6b46 100644 --- a/reader.c +++ b/reader.c @@ -2586,10 +2586,13 @@ wchar_t *reader_readline() case R_BACKWARD_KILL_LINE: { - wchar_t prev = data->buff[data->buff_pos]; - data->buff[data->buff_pos]=0; - kill_add( data->buff ); - data->buff[data->buff_pos]=prev; + wchar_t *str = wcsndup( data->buff, data->buff_pos ); + if( !str ) + die_mem(); + + kill_add( str ); + free( str ); + data->buff_len = wcslen(data->buff +data->buff_pos); memmove( data->buff, data->buff +data->buff_pos, sizeof(wchar_t)*data->buff_len ); data->buff[data->buff_len]=L'\0';