From de3e2b51862c5213818cec2776b3fa1bc43d1bfc Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 22 Apr 2014 10:42:06 +0200 Subject: [PATCH] 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. --- src/kits/interface/Gradient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/kits/interface/Gradient.cpp b/src/kits/interface/Gradient.cpp index b4cfc2a67a..ce922d41c7 100644 --- a/src/kits/interface/Gradient.cpp +++ b/src/kits/interface/Gradient.cpp @@ -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;