From ad69ae092320193424bb341030c8712d3db3fcf7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 1 Feb 2011 21:57:25 +0000 Subject: Avoid unsafe cast of int* to size_t* svn path=/trunk/netsurf/; revision=11597 --- desktop/textinput.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'desktop') diff --git a/desktop/textinput.c b/desktop/textinput.c index ea8d7d227..70fdca6c4 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -177,6 +177,7 @@ struct box *textarea_get_position(struct box *textarea, int x, int y, struct box *inline_container, *text_box; plot_font_style_t fstyle; + size_t char_offset = 0; inline_container = textarea->children; @@ -190,7 +191,7 @@ struct box *textarea_get_position(struct box *textarea, int x, int y, nsfont.font_position_in_string(&fstyle, text_box->text, text_box->length, (unsigned int)(x - text_box->x), - (size_t *) pchar_offset, ppixel_offset); + &char_offset, ppixel_offset); } else { /* find the relevant text box */ y -= inline_container->y; @@ -214,7 +215,7 @@ struct box *textarea_get_position(struct box *textarea, int x, int y, text_box->text, text_box->length, textarea->width, - (size_t *) pchar_offset, + &char_offset, ppixel_offset); } else { /* in a text box */ @@ -235,11 +236,13 @@ struct box *textarea_get_position(struct box *textarea, int x, int y, text_box->text, text_box->length, (unsigned int)(x - text_box->x), - (size_t *) pchar_offset, + &char_offset, ppixel_offset); } } + *pchar_offset = char_offset; + assert(text_box); return text_box; } -- cgit v1.2.3