changeset 28827: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 df0f40146b76
children 89e385b1d53a
files finch/libgnt/gntentry.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntentry.c	Tue Oct 27 07:58:50 2009 +0000
+++ b/finch/libgnt/gntentry.c	Tue Oct 27 23:35:45 2009 +0000
@@ -1044,8 +1044,11 @@
 		snprintf(entry->start, len + 1, "%s", text);
 	entry->end = entry->start + len;
 
-	entry->scroll = entry->start + scroll;
-	entry->cursor = entry->end - cursor;
+	if ((entry->scroll = entry->start + scroll) > entry->end)
+		entry->scroll = entry->end;
+
+	if ((entry->cursor = entry->end - cursor) > entry->end)
+		entry->cursor = entry->end;
 
 	if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED))
 		entry_redraw(GNT_WIDGET(entry));