BGradient: don't allow out of bounds stops.

* They crash app_server if you try to use them, which is not a good idea.
* we could clamp them to 0/255, but reporting the error to the user
seems better.
This commit is contained in:
Adrien Destugues
2014-04-22 10:45:24 +02:00
parent 574dbabb00
commit de3e2b5186
+4
View File
@@ -305,6 +305,10 @@ BGradient::SetColorStops(const BGradient& other)
int32
BGradient::AddColor(const rgb_color& color, float offset)
{
// Out of bounds stops would crash the app_server
if (offset < 0.f || offset > 255.f)
return -1;
// find the correct index (sorted by offset)
ColorStop* stop = new ColorStop(color, offset);
int32 index = 0;