[text] Ensure clutter_text_get_selection copes with start/end positions of -1

I was seeing clutter_text_get_selection trying to malloc up to 4Gb due to
unexpected negative arithmetic for the start/end offsets which resulted
in a crash.

This just tests for positions of -1 before deciding if the start/end
positions need to be swapped.  The conversion from position to byte offset
already works with -1.
This commit is contained in:
Robert Bragg 2009-05-13 12:11:54 +01:00
parent 979f089ef9
commit 2b1759385e

View File

@ -2859,7 +2859,8 @@ clutter_text_get_selection (ClutterText *self)
if (end_index == start_index)
return g_strdup ("");
if (end_index < start_index)
if ((end_index != -1 && end_index < start_index) ||
start_index == -1)
{
gint temp = start_index;
start_index = end_index;