Skip to content

Commit

Permalink
fixed: 对文本进行删除时导致的数据访问越界的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Mar 30, 2013
1 parent aa3458d commit ae48c24
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/font/textlayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,13 @@ TextLayer_Draw( LCUI_Widget *widget, LCUI_TextLayer *layer, int mode )
//clock_t start;
//start = clock();
//_DEBUG_MSG("enter\n");

if( widget == NULL || layer == NULL ) {
return;
}
graph = Widget_GetSelfGraph( widget );
if( graph == NULL ) {
return;
}
/* 如果文本缓存区内有数据 */
if( layer->need_proc_buff ) {
__TextLayer_Text( layer );
Expand Down Expand Up @@ -716,6 +721,9 @@ LCUI_EXPORT(void)
TextLayer_Text_Clear( LCUI_TextLayer *layer )
/* 清空文本内容 */
{
if( layer == NULL ) {
return;
}
TextLayer_Refresh( layer );
Queue_Destroy( &layer->text_source_data );
Queue_Destroy( &layer->rows_data );
Expand Down Expand Up @@ -783,6 +791,9 @@ TextLayer_Text_Process( LCUI_TextLayer *layer,
LCUI_CharData *char_ptr, char_data;
Text_RowData *cur_row_ptr, *tmp_row_ptr;

if( new_text == NULL ) {
return;
}
/* 如果有选中的文本,那就删除 */
//......
DEBUG_MSG1("enter\n");
Expand Down Expand Up @@ -1526,6 +1537,9 @@ TextLayer_Text_Backspace( LCUI_TextLayer *layer, int n )
DEBUG_MSG2( "before: %d,%d\n", char_pos.x, char_pos.y );
for( i=n; char_pos.y>=0; --char_pos.y ) {
row_ptr = Queue_Get( &layer->rows_data, char_pos.y );
if(row_ptr == NULL) {
continue;
}
row_len = Queue_GetTotal( &row_ptr->string );

if( char_pos.x == -1 ) {
Expand Down

0 comments on commit ae48c24

Please sign in to comment.