summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-22 23:30:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-22 23:30:27 +0000
commitc2a773b049cd039a3cdc342b9b414b9c43bc8821 (patch)
treee6512d1d69c6422365b9031c507ca447a9fd88b6 /desktop
parent3aa3708f178e1a72ec005de3cb0bb687d406b5cd (diff)
downloadnetsurf-c2a773b049cd039a3cdc342b9b414b9c43bc8821.tar.gz
netsurf-c2a773b049cd039a3cdc342b9b414b9c43bc8821.tar.bz2
Only attempt to find the next character in a string if we're not already at the end of the string.
svn path=/trunk/netsurf/; revision=6606
Diffstat (limited to 'desktop')
-rw-r--r--desktop/textinput.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/desktop/textinput.c b/desktop/textinput.c
index bae3dce35..927088331 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -455,8 +455,7 @@ bool browser_window_textarea_callback(struct browser_window *bw,
/* leave caret at join */
reflow = true;
- }
- else {
+ } else {
/* delete a character */
size_t next_offset = utf8_next(text_box->text,
text_box->length, char_offset);
@@ -1052,9 +1051,12 @@ bool browser_window_input_callback(struct browser_window *bw,
break;
}
- /* Go to the next valid UTF-8 character */
- box_offset = utf8_next(text_box->text, text_box->length,
- box_offset);
+ if (box_offset < text_box->length) {
+ /* Go to the next valid UTF-8 character */
+ box_offset = utf8_next(text_box->text,
+ text_box->length, box_offset);
+ }
+
break;
case KEY_LEFT: