comparison finch/libgnt/gntentry.c @ 28454:f36c4a76a7ac

Fix a couple of invalid reads after clearing the text in an entry box.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 27 Oct 2009 23:35:45 +0000
parents 650ab9eb4b21
children a18f421696dc
comparison
equal deleted inserted replaced
28453:df0f40146b76 28454:f36c4a76a7ac
1042 entry->start = g_new0(char, entry->buffer); 1042 entry->start = g_new0(char, entry->buffer);
1043 if (text) 1043 if (text)
1044 snprintf(entry->start, len + 1, "%s", text); 1044 snprintf(entry->start, len + 1, "%s", text);
1045 entry->end = entry->start + len; 1045 entry->end = entry->start + len;
1046 1046
1047 entry->scroll = entry->start + scroll; 1047 if ((entry->scroll = entry->start + scroll) > entry->end)
1048 entry->cursor = entry->end - cursor; 1048 entry->scroll = entry->end;
1049
1050 if ((entry->cursor = entry->end - cursor) > entry->end)
1051 entry->cursor = entry->end;
1049 1052
1050 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED)) 1053 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED))
1051 entry_redraw(GNT_WIDGET(entry)); 1054 entry_redraw(GNT_WIDGET(entry));
1052 } 1055 }
1053 1056