Fix to prevent buff_pos from underflowing in reader_kill

This commit is contained in:
ridiculousfish 2012-10-08 23:47:32 -07:00
parent 51de26960c
commit 3d5a3f03fa

View File

@ -494,7 +494,9 @@ static void reader_kill( size_t begin_idx, size_t length, int mode, int newv )
} }
if( data->buff_pos > begin_idx ) { if( data->buff_pos > begin_idx ) {
data->buff_pos = maxi( begin_idx, data->buff_pos-length ); /* Move the buff position back by the number of characters we deleted, but don't go past buff_pos */
size_t backtrack = mini(data->buff_pos - begin_idx, length);
data->buff_pos -= backtrack;
} }
data->command_line.erase(begin_idx, length); data->command_line.erase(begin_idx, length);